0
Help me cpp
Why this code cant pass code coach? Military time
4 Réponses
+ 1
thank u swim
0
#include <iostream>
using namespace std;
int main() {
string time,a,b;
getline(cin,time);
a=time.substr(6,2);
b=time.substr(0,2);
if(a=="pm"||a=="PM"||a=="Pm"){
if(b=="01"){
cout << "13"<<time.substr(2,4);
}
else if(b=="02"){
cout << "14"<<time.substr(2,4);
}
else if(b=="03"){
cout << "15"<<time.substr(2,4);
}
else if(b=="04"){
cout <<"16" <<time.substr(2,4);
}
else if(b=="05"){
cout << "17"<<time.substr(2,4);
}
else if(b=="06"){
cout << "18"<<time.substr(2,4);
}
else if(b=="07"){
cout << "19"<<time.substr(2,4);
}
else if(b=="08"){
cout << "20"<<time.substr(2,4);
}
else if(b=="09"){
cout << "21"<<time.substr(2,4);
}
else if(b=="10"){
cout << "22"<<time.substr(2,4);
}
else if(b=="11"){
cout << "23"<<time.substr(2,4);
}
else if(b=="12"){
cout << "00"<<time.substr(2,4);
}
}
else {cout<<time.substr(0,5);}
return 0;
}
0
thank u swim