两个点过不了,求助

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

KiritoFD @ 2024-07-17 14:44:39

#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d",&a,&b);
    if(a%b==0) c=a/b;
    else c=a/b+1;
    c+=10;
    c=c%1440;
    if(c>480) c=480+24*60-c;
    else c=480-c;
    int d,e;
    d=c/60;
    e=c%60;
    if(d<10) printf("0");
    printf("%d:%d",d,e);
    if(e==0) printf("0");
    return 0; 
 } 

by beigongbaishan @ 2024-07-17 14:51:15

我的代码:

#include<bits/stdc++.h>
using namespace std;
int main(){
    int s,v,l=480;
    cin>>s>>v;
    double t=ceil(s*1.0/v)+10;
    if(t>l)l=1920;
    l-=t;
    double t1=floor(l*1.0/60);
    if(t1>9)cout<<t1<<':';
    else cout<<0<<t1<<':';
    l-=t1*60;
    if(l>9)cout<<l;
    else cout<<0<<l;
}

by beigongbaishan @ 2024-07-17 14:51:46

求关~


by KiritoFD @ 2024-07-17 15:09:50

大佬,求C语言。。。。


by fa_e_tong @ 2024-07-18 10:01:24

//#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int s,v,t,oh,om,h,m;
int main()
{
    scanf("%d%d",&s,&v);
    t=s/v;
    if(s%v!=0) t+=1;
    t+=10;
    h=t/60;m=t%60;
    oh=h>8?(23-h+8):(7-h);//calculate hours
    om=60-m;
    oh<10?printf("0%d:",oh):printf("%d:",oh);//print hours
    om<10?printf("0%d",om):printf("%d",om);//print minutes
    return 0;
}

|