poj1005——I Think I Need a Houseboat
来源:互联网 发布:工业网络交换机厂家 编辑:程序博客网 时间:2024/06/07 07:57
家的坐标(X,Y)到侵蚀中心(0,0)的距离就是侵蚀半径R
那么Area = 1/2*PI*R 就是侵蚀面积
而侵蚀速度为每年50
那么侵蚀到Fred 家需要 year = Area/50 年
PS:因为要求从第一年开始计算,最后一年不够一年按一年计算,那么year+1取整就可以了。
#include<stdio.h>const double PI=3.141592654;int main(){ freopen("input.txt","r",stdin); int n; scanf("%d",&n); int i=1; for(i=1;i<=n;i++) { double x,y; scanf("%lf%lf",&x,&y); double Area; Area=0.5*PI*(x*x+y*y); int year; year=(int)(Area/50.0+1.0); printf("Property %d: This property will begin eroding in year %d.",i,year); printf("\n"); } printf("END OF OUTPUT."); return 0;}
PS:不知道为什么这段代码提交到poj时,语言如何选择C的话就过不了,C++才能过,我这不就是C代码么,错误都是说代码中的标识符没有声明,
希望有前辈路过能指导一下。
错误截图(C语言提交)
请教之后明白了一点,如果变量声明在循环之外就可以。
#include<stdio.h>const double PI=3.141592654;int main(){ freopen("input.txt","r",stdin); int n; int i=1; double Area; int year; double x,y; scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%lf%lf",&x,&y); Area=0.5*PI*(x*x+y*y); year=(int)(Area/50.0+1.0); printf("Property %d: This property will begin eroding in year %d.",i,year); printf("\n"); } printf("END OF OUTPUT."); return 0;}
0 0
- poj1005——I Think I Need a Houseboat
- poj1005——I Think I Need a Houseboat
- poj1005---I Think I Need a Houseboat
- POJ1005 I Think I Need a Houseboat
- POJ1005 I Think I Need a Houseboat
- poj1005 I Think I Need a Houseboat
- POJ1005 I Think I Need a Houseboat
- poj1005 -- I Think I Need a Houseboat
- POJ1005-I Think I Need a Houseboat
- poj1005(I Think I Need a Houseboat)
- POJ1005·I Think I Need a Houseboat
- poj1005"I Think I Need a Houseboat"解题报告
- POJ1005,I Think I Need a Houseboat,数学水题
- POJ1005-I Think I Need a Houseboat(水题)
- poj1005 I Think I Need a Houseboat 水题
- POJ1005(I Think I Need a Houseboat)(水题不水)
- POJ1005 I Think I Need a Houseboat【π】
- POJ——水刷 I Think I Need a Houseboat
- Linux11-Linux系统用户管理和用户组管理
- 关于TOleContainer在新窗体显示,并禁止工具条的方法,
- 构建Hadoop 2.2.0
- 删数 贪心
- 2013-2014计算机核心期刊排名
- poj1005——I Think I Need a Houseboat
- CentOS6.5下源码安装gcc-4.8.2安装笔记整理
- 内核态下基于动态感染技术的应用程序执行保护(五 动态感染)
- Qt Creator + opencv2.4.6
- 小白linux bash 学习一 变量定义
- 高速数据采集记录存储回放系统—记录存储带宽6GB/S!
- priority_queue
- 用C#创建PDF表格:iTextSharp的应用
- 辽宁义县第一运输公司魏奇 多年如一日踏实做事BqaSwNK