Advertisement
Goga21

Untitled

Mar 28th, 2024
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. #define int long long
  4.  
  5. using namespace std;
  6.  
  7. signed main(){
  8. int t;
  9. cin >> t;
  10. while(t--) {
  11. string s;
  12. cin >> s;
  13. if(s[0] == '1' && s[1] == '2'){
  14. cout << s << " PM\n";
  15. }else if(s[0] == '1' && s[1] > '2'){
  16. s[0] = '0';
  17. s[1] -= 2;
  18. cout << s << " PM\n";
  19. }else if(s[0] == '0' && s[1] == '0'){
  20. s[0] = '1';
  21. s[1] = '2';
  22. cout << s << " AM\n";
  23. }else if(s[0] == '2'){
  24. if(s[1] == '4'){
  25. s[0] = '0';
  26. s[1] = '0';
  27. cout << s << " PM\n";
  28. }else{
  29. int time = (s[0] - '0') * 10 + s[1] - '0';
  30. time %= 12;
  31. cout << "0" << time << ":" << s[3] << s[4] << " PM\n";
  32. }
  33. }else{
  34. cout << s << " AM\n";
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement