SlideShare une entreprise Scribd logo
1  sur  2
Does anyone can help me fix this problem using c langauge?
Thank you so much!
Solution
/* calculate polygon perimeter */
double perimeter(double *vertices, int size)
{
int idx, jdx;
double p1[2], p2[2], pfirst[2], plast[2];
double perimeter;
perimeter = 0.0;
/* 1st vertex of the polygon */
pfirst[x] = vertices[0];
pfirst[y] = vertices[1];
/* last vertex of polygon */
plast[x] = vertices[size-2];
plast[y] = vertices[size-1];
/* calculate perimeter minus last side */
for(idx = 0; idx <= size-3; idx += 2)
{
for(jdx = 0; jdx < 4; ++jdx)
{
p1[x] = vertices[idx];
p1[y] = vertices[idx+1];
p2[x] = vertices[idx+2];
p2[y] = vertices[idx+3];
}
perimeter += side(p1, p2);
}
/* add last side */
perimeter += side(plast, pfirst);
return perimeter;
}
vertices means array of vertices stored

Contenu connexe

Plus de wviola

Action Center activation Administrative Tools Aero applets Computer Co (1).docx
Action Center activation Administrative Tools Aero applets Computer Co (1).docxAction Center activation Administrative Tools Aero applets Computer Co (1).docx
Action Center activation Administrative Tools Aero applets Computer Co (1).docxwviola
 
Acid lonization Constants (K-) for Some Monoprotic Weak Acids at 25 ec.docx
Acid lonization Constants (K-) for Some Monoprotic Weak Acids at 25 ec.docxAcid lonization Constants (K-) for Some Monoprotic Weak Acids at 25 ec.docx
Acid lonization Constants (K-) for Some Monoprotic Weak Acids at 25 ec.docxwviola
 
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 6Solut.docx
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 6Solut.docxAC 556 Accounting for Governmental & Nonprofit Entities Chapter 6Solut.docx
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 6Solut.docxwviola
 
Accounting Which of the following is true of a corporation- OA- The st.docx
Accounting Which of the following is true of a corporation- OA- The st.docxAccounting Which of the following is true of a corporation- OA- The st.docx
Accounting Which of the following is true of a corporation- OA- The st.docxwviola
 
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 7Solut.docx
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 7Solut.docxAC 556 Accounting for Governmental & Nonprofit Entities Chapter 7Solut.docx
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 7Solut.docxwviola
 
advantages and disadvantages of using centralized network management v.docx
advantages and disadvantages of using centralized network management v.docxadvantages and disadvantages of using centralized network management v.docx
advantages and disadvantages of using centralized network management v.docxwviola
 
Advantages & Disadvantages of Server Applications in 150+ wordsSolutio.docx
Advantages & Disadvantages of Server Applications in 150+ wordsSolutio.docxAdvantages & Disadvantages of Server Applications in 150+ wordsSolutio.docx
Advantages & Disadvantages of Server Applications in 150+ wordsSolutio.docxwviola
 
Does any one have a paper on human resource practices in countries bes.docx
Does any one have a paper on human resource practices in countries bes.docxDoes any one have a paper on human resource practices in countries bes.docx
Does any one have a paper on human resource practices in countries bes.docxwviola
 
Do you think Facebook should operate in China even if it means complyi.docx
Do you think Facebook should operate in China even if it means complyi.docxDo you think Facebook should operate in China even if it means complyi.docx
Do you think Facebook should operate in China even if it means complyi.docxwviola
 
Do you think contingent gains should be disclosed in the financial sta (1).docx
Do you think contingent gains should be disclosed in the financial sta (1).docxDo you think contingent gains should be disclosed in the financial sta (1).docx
Do you think contingent gains should be disclosed in the financial sta (1).docxwviola
 
Do you think contingent gains should be disclosed in the financial sta.docx
Do you think contingent gains should be disclosed in the financial sta.docxDo you think contingent gains should be disclosed in the financial sta.docx
Do you think contingent gains should be disclosed in the financial sta.docxwviola
 
Do you believe the double taxation of earnings which occurs at the cor.docx
Do you believe the double taxation of earnings which occurs at the cor.docxDo you believe the double taxation of earnings which occurs at the cor.docx
Do you believe the double taxation of earnings which occurs at the cor.docxwviola
 
Do you believe that the Patriot Act was an appropriate risk response t.docx
Do you believe that the Patriot Act was an appropriate risk response t.docxDo you believe that the Patriot Act was an appropriate risk response t.docx
Do you believe that the Patriot Act was an appropriate risk response t.docxwviola
 
Do you believe that Bernard Madoff worked alone- or do you think he ha.docx
Do you believe that Bernard Madoff worked alone- or do you think he ha.docxDo you believe that Bernard Madoff worked alone- or do you think he ha.docx
Do you believe that Bernard Madoff worked alone- or do you think he ha.docxwviola
 
Do you agree with Scott McNealy-'s statement that people have --zero p.docx
Do you agree with Scott McNealy-'s statement that people have --zero p.docxDo you agree with Scott McNealy-'s statement that people have --zero p.docx
Do you agree with Scott McNealy-'s statement that people have --zero p.docxwviola
 
Do the six attributes of an ideal health system capture all the major.docx
Do the six attributes of an ideal health system capture all the major.docxDo the six attributes of an ideal health system capture all the major.docx
Do the six attributes of an ideal health system capture all the major.docxwviola
 
Do research to identify the current countries that are identified as -.docx
Do research to identify the current countries that are identified as -.docxDo research to identify the current countries that are identified as -.docx
Do research to identify the current countries that are identified as -.docxwviola
 
Do governments and companies in developed countries have an ethical re.docx
Do governments and companies in developed countries have an ethical re.docxDo governments and companies in developed countries have an ethical re.docx
Do governments and companies in developed countries have an ethical re.docxwviola
 
Do a literature survey to identify the first paper on 3 topics of the.docx
Do a literature survey to identify the first paper on 3 topics of the.docxDo a literature survey to identify the first paper on 3 topics of the.docx
Do a literature survey to identify the first paper on 3 topics of the.docxwviola
 
Divide and check- T2 - 13-t - 4Solution(t2 - 13)-(t - 4) Do division-.docx
Divide and check-  T2 - 13-t - 4Solution(t2 - 13)-(t - 4) Do division-.docxDivide and check-  T2 - 13-t - 4Solution(t2 - 13)-(t - 4) Do division-.docx
Divide and check- T2 - 13-t - 4Solution(t2 - 13)-(t - 4) Do division-.docxwviola
 

Plus de wviola (20)

Action Center activation Administrative Tools Aero applets Computer Co (1).docx
Action Center activation Administrative Tools Aero applets Computer Co (1).docxAction Center activation Administrative Tools Aero applets Computer Co (1).docx
Action Center activation Administrative Tools Aero applets Computer Co (1).docx
 
Acid lonization Constants (K-) for Some Monoprotic Weak Acids at 25 ec.docx
Acid lonization Constants (K-) for Some Monoprotic Weak Acids at 25 ec.docxAcid lonization Constants (K-) for Some Monoprotic Weak Acids at 25 ec.docx
Acid lonization Constants (K-) for Some Monoprotic Weak Acids at 25 ec.docx
 
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 6Solut.docx
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 6Solut.docxAC 556 Accounting for Governmental & Nonprofit Entities Chapter 6Solut.docx
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 6Solut.docx
 
Accounting Which of the following is true of a corporation- OA- The st.docx
Accounting Which of the following is true of a corporation- OA- The st.docxAccounting Which of the following is true of a corporation- OA- The st.docx
Accounting Which of the following is true of a corporation- OA- The st.docx
 
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 7Solut.docx
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 7Solut.docxAC 556 Accounting for Governmental & Nonprofit Entities Chapter 7Solut.docx
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 7Solut.docx
 
advantages and disadvantages of using centralized network management v.docx
advantages and disadvantages of using centralized network management v.docxadvantages and disadvantages of using centralized network management v.docx
advantages and disadvantages of using centralized network management v.docx
 
Advantages & Disadvantages of Server Applications in 150+ wordsSolutio.docx
Advantages & Disadvantages of Server Applications in 150+ wordsSolutio.docxAdvantages & Disadvantages of Server Applications in 150+ wordsSolutio.docx
Advantages & Disadvantages of Server Applications in 150+ wordsSolutio.docx
 
Does any one have a paper on human resource practices in countries bes.docx
Does any one have a paper on human resource practices in countries bes.docxDoes any one have a paper on human resource practices in countries bes.docx
Does any one have a paper on human resource practices in countries bes.docx
 
Do you think Facebook should operate in China even if it means complyi.docx
Do you think Facebook should operate in China even if it means complyi.docxDo you think Facebook should operate in China even if it means complyi.docx
Do you think Facebook should operate in China even if it means complyi.docx
 
Do you think contingent gains should be disclosed in the financial sta (1).docx
Do you think contingent gains should be disclosed in the financial sta (1).docxDo you think contingent gains should be disclosed in the financial sta (1).docx
Do you think contingent gains should be disclosed in the financial sta (1).docx
 
Do you think contingent gains should be disclosed in the financial sta.docx
Do you think contingent gains should be disclosed in the financial sta.docxDo you think contingent gains should be disclosed in the financial sta.docx
Do you think contingent gains should be disclosed in the financial sta.docx
 
Do you believe the double taxation of earnings which occurs at the cor.docx
Do you believe the double taxation of earnings which occurs at the cor.docxDo you believe the double taxation of earnings which occurs at the cor.docx
Do you believe the double taxation of earnings which occurs at the cor.docx
 
Do you believe that the Patriot Act was an appropriate risk response t.docx
Do you believe that the Patriot Act was an appropriate risk response t.docxDo you believe that the Patriot Act was an appropriate risk response t.docx
Do you believe that the Patriot Act was an appropriate risk response t.docx
 
Do you believe that Bernard Madoff worked alone- or do you think he ha.docx
Do you believe that Bernard Madoff worked alone- or do you think he ha.docxDo you believe that Bernard Madoff worked alone- or do you think he ha.docx
Do you believe that Bernard Madoff worked alone- or do you think he ha.docx
 
Do you agree with Scott McNealy-'s statement that people have --zero p.docx
Do you agree with Scott McNealy-'s statement that people have --zero p.docxDo you agree with Scott McNealy-'s statement that people have --zero p.docx
Do you agree with Scott McNealy-'s statement that people have --zero p.docx
 
Do the six attributes of an ideal health system capture all the major.docx
Do the six attributes of an ideal health system capture all the major.docxDo the six attributes of an ideal health system capture all the major.docx
Do the six attributes of an ideal health system capture all the major.docx
 
Do research to identify the current countries that are identified as -.docx
Do research to identify the current countries that are identified as -.docxDo research to identify the current countries that are identified as -.docx
Do research to identify the current countries that are identified as -.docx
 
Do governments and companies in developed countries have an ethical re.docx
Do governments and companies in developed countries have an ethical re.docxDo governments and companies in developed countries have an ethical re.docx
Do governments and companies in developed countries have an ethical re.docx
 
Do a literature survey to identify the first paper on 3 topics of the.docx
Do a literature survey to identify the first paper on 3 topics of the.docxDo a literature survey to identify the first paper on 3 topics of the.docx
Do a literature survey to identify the first paper on 3 topics of the.docx
 
Divide and check- T2 - 13-t - 4Solution(t2 - 13)-(t - 4) Do division-.docx
Divide and check-  T2 - 13-t - 4Solution(t2 - 13)-(t - 4) Do division-.docxDivide and check-  T2 - 13-t - 4Solution(t2 - 13)-(t - 4) Do division-.docx
Divide and check- T2 - 13-t - 4Solution(t2 - 13)-(t - 4) Do division-.docx
 

Dernier

Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Association for Project Management
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptxJonalynLegaspi2
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptxDhatriParmar
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQuiz Club NITW
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 

Dernier (20)

Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptx
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 

Does anyone can help me fix this problem using c langauge- Thank you s.docx

  • 1. Does anyone can help me fix this problem using c langauge? Thank you so much! Solution /* calculate polygon perimeter */ double perimeter(double *vertices, int size) { int idx, jdx; double p1[2], p2[2], pfirst[2], plast[2]; double perimeter; perimeter = 0.0; /* 1st vertex of the polygon */ pfirst[x] = vertices[0]; pfirst[y] = vertices[1]; /* last vertex of polygon */ plast[x] = vertices[size-2]; plast[y] = vertices[size-1]; /* calculate perimeter minus last side */ for(idx = 0; idx <= size-3; idx += 2) { for(jdx = 0; jdx < 4; ++jdx) { p1[x] = vertices[idx]; p1[y] = vertices[idx+1]; p2[x] = vertices[idx+2]; p2[y] = vertices[idx+3]; } perimeter += side(p1, p2); } /* add last side */ perimeter += side(plast, pfirst); return perimeter; }
  • 2. vertices means array of vertices stored