Skip to content

Instantly share code, notes, and snippets.

@modos
Created July 13, 2022 21:24
Show Gist options
  • Save modos/0dcf7b9003c4221eb99dc131ddd1801f to your computer and use it in GitHub Desktop.
Save modos/0dcf7b9003c4221eb99dc131ddd1801f to your computer and use it in GitHub Desktop.
یک ساعت
#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