#3,5求助

P5707 【深基2.例12】上学迟到

dazahui @ 2023-09-07 09:44:20

#include<bits/stdc++.h>

using namespace std;

int main()

{

    int s=0;
     int v=0;
    scanf("%d %d",&s,&v);
    float t1=s*1.0/v;
    int t2=0;
    if (t1-s/v!=0)
   {
       t2=(int)t1+1;
     }
     else 
   {
        t2=(int)t1;
     }
     int t=t2+10;
     int H=8,MM=0;
     if(t<=480)
    {
        if(t%60==0){
            printf("0%d:00",H-t/60);
        }
        else 
        {
            printf("0%d:%d",H-t/60-1,MM=60-t%60);
        }
    }
       else{
            int t3=t-480;
            if(t3%60==0){
                 printf("%02d:00",24-t3/60);
            }
            else {
                printf("%02d:%02d",24-t3/60-1,60-t3%60);
            }

      return 0;

 } 

by repartor007 @ 2023-09-09 16:50:48

printf("0%d:%d",H-t/60-1,MM=60-t%60);

冒号后也要输出两位数吧,不然可能会05:7之类的。


by Redeption @ 2023-09-10 15:29:10

@repartor007 是的提醒我了


by dazahui @ 2023-09-11 08:29:26

@repartor007 明白了,非常感谢


|