| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
代码没看,但小心各种猥琐的前导0(我没违规吧— —bbb)In Reply To:怎么老是WA,大虾帮看看 Posted by:HIT_Happy at 2010-01-05 13:15:21 > #include <iostream>
> #include <string>
> using namespace std;
> //3751
> int main(void)
> {
> int num,ihour;
> string strDatatime,strDate,strTime,strYear,strMoth;
> string strhour,strMin;
> char ch;
>
> cin>>num;
> for (int i =0;i<num;i++)
> {
> ch = '-';
> cin>>strDatatime;
> int index = strDatatime.find(ch);
> strDate = strDatatime.substr(0,index);
> strTime = strDatatime.substr(index+1,strDatatime.length());
>
> ch = '/';
> index = strDate.find(ch);
> strYear = strDate.substr(0,index);
> strMoth = strDate.substr(index+1,strDate.length());
>
> ch = ':';
> index = strTime.find(ch);
> strhour = strTime.substr(0,index);
> strMin = strTime.substr(index+1,strTime.length());
>
> ihour = atoi(strhour.c_str());
>
> cout<<strMoth<<"/"<<strYear<<"-";
> if(ihour>12)
> {
> if(ihour>21)
> cout<<ihour-12<<":"<<strMin<<"pm";
> else
> cout<<"0"<<ihour-12<<":"<<strMin<<"pm";
> }
> else if(ihour == 0)
> cout<<"12:"<<strMin<<"am";
> else if(ihour == 12)
> cout<<"12:"<<strMin<<"pm";
> else
> cout<<ihour<<":"<<strMin<<"am";
> cout<<endl;
>
> }
>
> return 0;
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator