为啥0分?

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

kitkit @ 2024-08-25 10:39:10

测试好好的,就是0分,不知道为啥

#include<stdio.h>
int main(){
    double s,v;
    int m;
    scanf("%d%d",&s,&v);
    m=24*60-(s/v+10)+8*60;
    printf("%02d:%02d",(m/60)%24,m%60);
    return 0;
}

by 天南星魔芋 @ 2024-08-25 10:45:25

@kitkit

scanf 读入 double 不是 %d 而是 %lf

#include<stdio.h>
int main(){
    double s,v;
    int m;
    scanf("%lf%lf",&s,&v);
    m=24*60-(s/v+10)+8*60;
    printf("%02d:%02d",(m/60)%24,m%60);
    return 0;
}

by Jason_Teng @ 2024-08-25 10:46:43

新手菜坤建议用cin,cout @kitkit


by cygh_xiaoC_12 @ 2024-08-25 10:49:03

@kitkit scanf("%d")是输入int类型,doublescanf("%lf")


by kitkit @ 2024-08-25 10:53:09

@天南星魔芋 谢谢提醒


by kitkit @ 2024-08-25 10:55:19

@shabiJason 可我学的是C


by kitkit @ 2024-08-25 10:56:28

dev用这个也行,无语


by 天南星魔芋 @ 2024-08-25 11:04:12

@kitkit 确实,我之前CSP被这个坑过一回


|