816A Codeforces - Karen and Morning


816A Codeforces - Karen and Morning




Solution in c++

#include <bits/stdc++.h>
using namespace std;
string a,b;
int mn;
string plsm(string x)
{
        if(x[1]<'9')x[1]++;
        else if(x[1]=='9'&& x[0]<'5'){x[0]++;x[1]='0';}
        else if(x[1]=='9'&& x[0]=='5'){x="00";}
        return x;
}
string plsh(string x)
{
        if(x=="23"){x="00";}
        else if(x[1]=='9'&& x[0]<'2'){x[0]++;x[1]='0';}
        else if(x[1]<'9'&& x[0]<='2'){x[1]++;}
        return x;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    getline(cin,a,':');cin>>b;
    while( a[0] != b[1]  || a[1]!=b[0] )
    {
        mn++;
        if(b=="59"){b="00";a=plsh(a);continue;}
        b=plsm(b);
    }
    cout<<mn;
    return 0;
}


Share on Google Plus

About Mohamed Sobhi

My name is Mo.Sobhy ,I study at School excelling high school in Ain Shams ,Cairo
My hobbies is programming ,and web development ,playing chess and writing horror stories.
    Blogger Comment
    Facebook Comment

0 التعليقات:

إرسال تعليق