1 solutions

  • 0
    @ 2022-11-28 10:36:48

    6662. 善良的马同学来给你们出签到题了

    这道题思路很简单,别搞什么巨多选择分支,太麻烦了,就把24小时制转化为分钟,然后加上时间n之后再转化回去就行了。

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        int n;
        cin>>n;
        int h,m;
        scanf("%d:%d",&h,&m);
        int fm=(h*60+m+n)%60;
        int fh=(h*60+m+n)/60%24;
        printf("%.2d:%.2d",fh,fm);
        return 0;
    }
    
    • 1

    Information

    ID
    6662
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    7
    Tags
    (None)
    # Submissions
    272
    Accepted
    53
    Uploaded By