正文

C++吧第2界编程大赛(网友算法)2005-11-29 15:23:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/elva6401/7575.html

分享到:

//第一题(222.173.180.*   ) #define leap(year) ((!(year%4) && year%100) || !(year%400))  int main() {   long year,month=1,day=1; //program safty??? printf("please input the date:format like YYYY-MM-DD\n"); scanf("%d-%d-%d",&year,&month,&day);  month>10?year++,month-=10:month+=2; //month okey... if(day==31&&month==9) day=30; //kill 31  if(day>28&&month==2) leap(year)?day=29:day=28; printf("%.4d-%.2d-%.2d\n",year,month,day); //out  return 0; } //第2题(Soningwl) #include<iostream.h>  #include<math.h>  int main()  {  cout<<"请输入一个年份:(1946-2246)";  int num;   cin>>num;  long double a;  a=pow(2,(num-1946)/10);  int i=1;  long double sum=0;  for(;sum<a*log(2);i++)sum+=log(i);  cout<<"此年的阶层为:"<<i-2<<"\n";  return 0;  }  

阅读(4281) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册