?? points.c
字號:
#include <stdio.h>
#define MAX_LINE_N 15
int main()
{
double point[MAX_LINE_N+1][2]={0,0};
int i=0, j=0;
double area=0.0;
//get x and y from stdin
while(scanf("%lf%lf", &point[i][0], &point[i][1]) != EOF)
i++;
//copy the first point to the position behind the last point
point[i][0] = point[0][0];
point[i][1] = point[0][1];
//compute the area of polygon by dividing it into several trapezoids
for (j=0; j<i; j++)
area += (point[j][1] - point[j+1][1]) * (point[j][0] + point[j+1][0]) / 2;
//print the area retaining two decimal
printf("%.2f", area);
return 0;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -