万恶的oj笔记之【111030】

平常两个小时搞定的题目,整搞了2天 T.T 还是要总结 hdoj2002-- 没事做多用double,scanf时用%lf,除非有内存限制,但貌似现在还谈不上。 printf时%4.3f别写成%4,3f ---------------------------- #include #define PI 3.1415927 int main() { double a; while(scanf("%lf",&a)!=EOF) { printf("%4.3f\n",(4*a*a*a*PI)/3); } return 0; } --------------------------------- hdoj2003 输出格式问题。。。 ----------------------------- #include int main() { double a; while(scanf("%lf",&a)!=EOF) { if (a>0) { printf("%3.2f\n",a); }else { printf("%3.2f\n",-a); } } return 0; } ----------------------------------- hdoj2004 老生常谈的“;” -------------------------------------- #include int main() { double a; while(scanf("%lf",&a)!=EOF) { if (a>=90&&a<=100) { printf("A\n"); }else { if (a>=80&&a<=89) { printf("B\n"); }else { if (a>=70&&a<=79) { printf("C\n"); }else { if (a>=60&&a<=69) { printf("D\n"); }else { if (a>=0&&a<=59) { printf("E\n"); }else { printf("Score is error!\n"); } } } } } } return 0; } ---------------------------- hdoj2005 不知道怎么回事,int最好是就放在int main()的后面,否则会报错。我到现在都不知道是为什么。。 ------------------------------- #include int is_run_year(int b) { if ((b%4==0&&b%100!=0)||(b%400==0)) { return 1; }else { return 0; } } int deal_yue(int a) { if (a==1||a==3||a==5||a==7||a==8||a==10||a==12) { return 31; }else { if(a==2) { return 28; } else { return 30; } } } int main() { int y,m,d; while(scanf("%d/%d/%d",&y,&m,&d)!=EOF) { int total=0; int i=0; if(is_run_year(y)&&(m>=3)) { total=total+1; } for(i=1;i<=(m-1);i++) { total=total+deal_yue(i); } total=total+d; printf("%d\n",total); } return 0; } ----------------------------- hdoj2006 动态数组的创建,要弄明白。 看清题意。避免粗心。 ------------- Online Judge Online Exercise Online Teaching Online Contests Exercise Author F.A.Q Hand In Hand Online Acmers Forum | Discuss Statistical Charts Problem Archive Realtime Judge Status Authors Ranklist C/C++/Java Exams ACM Steps Code Challenge Recent Contests ICPC@China STD Contests VIP Contests Virtual Contests DIY | Web-DIY beta Contest LiveCast 77695 Mail 0(0) Control Panel Sign Out New~关于举办大学生程序设计竞赛(新生杯)的报名通知 ***报名入口*** ***查看报名*** 杭电2010和2011级同学如何加入ACM集训队? View Code Problem : 2006 ( 求奇数的乘积 ) Judge Status : Accepted RunId : 4855243 Language : C++ Author : 77695 Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta #include int main() { int a; int i=0; int sum=1; while(scanf("%d",&a)!=EOF) { sum=1; int *s =new int[a]; for(i=0;i<=(a-1);i++) { scanf("%d",&s[i]); } for(i=0;i<=(a-1);i++) { if (s[i]%2==1) { sum=sum*s[i]; } } printf("%d\n",sum); } return 0; } #include int main() { int a; int i=0; int sum=1; while(scanf("%d",&a)!=EOF) { sum=1; int *s =new int[a]; for(i=0;i<=(a-1);i++) { scanf("%d",&s[i]); } for(i=0;i<=(a-1);i++) { if (s[i]%2==1) { sum=sum*s[i]; } } printf("%d\n",sum); } return 0; } ------------------------ hdoj2007 如果说要在两个数之间取连续的数。一定要确定好两个数的大小。 看清题意TT -------------------------- #include int main() { long unsigned a,b; long unsigned i=0; long unsigned sum_ou_pfh=0,sum_ji_lfh=0; long unsigned t; while(scanf("%ld%ld",&a,&b)!=EOF) { sum_ou_pfh=0; sum_ji_lfh=0; if (a>b) { t=a; a=b; b=t; } for(i=a;i<=b;i++) { if(i%2!=1) { sum_ou_pfh=sum_ou_pfh+i*i; } else { sum_ji_lfh=sum_ji_lfh+i*i*i; } } printf("%ld %ld\n",sum_ou_pfh,sum_ji_lfh); } return 0; } ----------------- 待续。。。。

你可能感兴趣的:(笔记)