摘要:
这道题的大致意思: 圆表示一块面积可扩展的区域,开始时,面积是0,在(0,0)处开始以每年50平方米的速度同样呈半圆扩展,输入一个正整数N,然后输入N对坐标,对于每一对坐标值:求出面积扩展到该点的年数,坐标值单位为米。 理解意思后此题就水很多了。细心的话一次搞定~ #include <iostream>#include <cstdio>#include <cmath>using namespace std;const double PI=3.1415926;int main(){ int n; cin>>n; for(int i=1;i<= 阅读全文
posted @ 2011-05-31 17:51
andyidea
阅读(903)
评论(0)
推荐(1)
摘要:
求12个月工资的平均数。这个题的难度和1001差不多吧 1 #include <iostream> 2 using namespace std; 3 4 5 int main() 6 { 7 int n=12; 8 float sum=0.0; 9 float a;10 while(n--)11 {12 cin>>a;13 sum+=a;14 }15 cout<<"$"<<sum/12<<endl;16 17 18 return 0;19 } 阅读全文
posted @ 2011-05-31 17:02
andyidea
阅读(218)
评论(0)
推荐(0)
摘要:
题意还是比较容易理解的,题上已经给出了公式。求1/2+1/3+1/4+...+1/(n+1)>=x的最小n的值,稍微注意点的就是浮点型了,貌似很多人都WA过,都是错在浮点数的。。代码实现#include <iostream>using namespace std;int main(){ float f; while(cin>>f,f) { float n=2.0; float sum=0.0; while(1) { sum+=1.0/n; if(sum>=f) break; n+=1.0; } cout<<(int)n-1<<&quo 阅读全文
posted @ 2011-05-31 11:21
andyidea
阅读(311)
评论(0)
推荐(1)