游览珠海校区
来源:互联网 发布:如何加强网络安全管理 编辑:程序博客网 时间:2024/06/11 17:41
游览珠海校区
描述
The 1^st Annual Guangdong Collegiate Programming Contest (GDCPC) was held in Zhuhai Campus of Zhongshan (Sun Yat-Sen) university last year. And now we gather again for the 2^nd GDCPC in the same wonderful place. After the contest, most of the participants will probably have a jaunt around the beautiful Campus.
As you have seen, the main attraction of this place is the green hills surrounding. And a problem comes up now. What is the area of cross section of the hills?
This range of hills contains peaks and valleys. So before calculating the area, we have to firstly scale and write down the coordinates of the turning points. In the following graph, 7 turning points of a hill are marked.
输入
The first line of the input is a positive integer T. T is the number of the test cases followed.
The first line of each test cases contains only one positive integer N (1 <= N <= 1000) which represents the number of the turning points. Then N lines follow and the i^th line contains two nonnegative integers Xi (0 <= Xi <= 10000), Yi (0 <= Yi <= 10000) which represent the coordinate of the i^th turning point. It is assumed that the given turning points is in X-coordinate increasing order, i.e. Xi < Xj when I < j.
输出
The output of the program should consist of one line of output for each test case. The output of each test case only contains one real number which represents the area of the cross section of the hills. The real numbers are rounded to one decimal digit. No redundant spaces are needed.
样例输入
2
1 4
3 4
2
2 7
3 9
样例输出
8.0
#include <stdio.h>#include <math.h>int main (){ int w, z, i, j; double sum, x[10005], y[10005]; scanf("%d",&w); while(w--) { sum = 0; scanf("%d",&z); for(i = 0; i < z; ++i) scanf("%lf %lf",&x[i],&y[i]); for(j = 1; j < z; ++j) ///对每个梯形求面积并算总和 sum = sum + (y[j] + y[j-1]) * (x[j] - x[j-1])/2; printf("%.1f\n",sum); } return 0;}
- 游览珠海校区
- 珠海游记
- 珠海港
- 在珠海
- 珠海行
- 游览tree
- 游览江西
- 玉渊潭游览
- 游览器及游览器内核
- 天津工业大学老校区
- 天津工业大学新校区
- 洛阳行-老校区
- 珠海之行
- 深圳珠海自助行
- 去了珠海
- 2008珠海赛总结
- 珠海与深圳
- 珠海紧急二日游
- TP-LINK利用MAC绑定限制上网用户
- Linux Shell常用技巧(三)
- IOS开发之Cocoa编程—— NSUndoManager
- (五)实现更多功能
- 测试Qt的数据库驱动支持
- 游览珠海校区
- 欧拉公式
- Linux Shell常用技巧(四)
- 【PHP】 LINUX PHP执行
- 《数据结构》各章教学资源
- 点乘,叉乘总结
- Linux Shell常用技巧(五)
- sgu 108 self number(数学问题滚动数组)
- QT编程系列10--客户端的网络编程