HDU-2005
来源:互联网 发布:java快速排序简单代码 编辑:程序博客网 时间:2024/05/21 23:39
#include<iostream>#include<string>using namespace std;int main(){string date;int daysOfMonth[]={31,28,31,30,31,30,31,31,30,31,30,31};while(cin>>date){int year,month,day;string y,m,d;int sum=0;int pos1=0,pos2=0;for(int i=0;i<date.length();i++){if(date[i]=='/'){pos1=i;break;}}for(int i=0;i<date.length();i++){if(date[i]=='/'){pos2=i;}}y=date.substr(0,pos1);m=date.substr(pos1+1,pos2-pos1-1);d=date.substr(pos2+1);year = atoi(y.c_str());month = atoi(m.c_str());day = atoi(d.c_str());if( ( ( year%4 == 0) && (year%100 != 0)) || ( year%400 == 0) ){daysOfMonth[1]=29;}else{daysOfMonth[1]=28;}for(int i=0;i<month;i++){sum+=daysOfMonth[i];}sum=sum-(daysOfMonth[month-1]-day);cout<<sum<<endl;}return 0;}
总结:
1.代码基础不够扎实,花费较多时间研究字符串的用法完成解题
2.题意逻辑不够清楚表达,如:(year%100 != 0)这个条件漏写,导致3A
3.虽然3A但是起码是自己完成的啊,大水逼都是这样进化的
0 0
- hdu 2005
- hdu 2005
- HDU 2005
- HDU-2005
- hdu 2005
- HDU 2005
- HDU 2005
- HDU 2005
- HDU-2005
- HDU 2005
- HDU-2005
- hdu 2005
- HDU 2005
- hdu 2005 第几天
- hdu 2005 java_calendar
- HDU 2005 第几天
- HDU 2005 第几天?
- hdu 2005 第几天?
- 欢迎使用CSDN-markdown编辑器
- 修改linux文件权限命令:chmod
- 配置文件 etc/config/****qos
- Java was started but returned exit code=13 JDK与eclipse版本问题
- 基于平台的标准增删改
- HDU-2005
- C语言里的左移和右移运算
- 是否可以从一个static方法内部发出对非static方法的调用?
- 初识Maven
- viewpager广告位滑动速度控制
- jquery通过ajax在jsp中局部刷新页面
- infoq上关于微服务的几篇文章
- CronTrigger spring定时任务
- git 解决pull origin 错误 error: The following untracked working tree files would be overwritten by merge