Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 怎么老是WA,大虾帮看看

Posted by HIT_Happy at 2010-01-05 13:15:21 on Problem 3751
```#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: