Created
July 13, 2022 21:24
-
-
Save modos/0dcf7b9003c4221eb99dc131ddd1801f to your computer and use it in GitHub Desktop.
یک ساعت
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
int a,b; | |
cin >> a >> b; | |
if ( a > 12 && a < 24){ | |
a = a - 12; | |
if ( b != 0){ | |
b = 60 - b; | |
} | |
}else if ( a < 12 && a != 0){ | |
a = 12 - a; | |
if (b != 0 && a != 6){ | |
b = 60 - b; | |
} | |
}else if ( a == 12 ) { | |
a = 12 - a; | |
if ( b != 0){ | |
b = 60 - b; | |
} | |
}else if ( a == 24 ) { | |
a = 0; | |
}else if (a == 0){ | |
if ( b != 0){ | |
b = 60 - b; | |
} | |
} | |
string h = a > 9 ? to_string(a) : "0" + to_string(a); | |
string m = b > 9 ? to_string(b) : "0" + to_string(b); | |
cout << h << ":" << m; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment