为了账号安全,请及时绑定邮箱和手机立即绑定

#include <stdio.h> int main() { int i=12,sum,n=2; if(i<=3) { sum=13; printf("%d",sum); } sum=(i-3)*2.3+sum; for(n=2;n>=1;n--) { sum +=1;} printf("总费用%f",sum); return 0; }

为什么算出来是0

正在回答

2 回答

#include <stdio.h>

int main()

{

    float kilometre=2.3;

    int k=13;

    int a=1;

    int time=9;

    float money;

    {

        if(time>=23&&time<5){

            money=k+(kilometre+kilometre*0.2)+a;

            printf("小明打车一共花%f",money);

        }else{

            money=k+kilometre+a;

        printf("小明打车一共花%f",money);

        }

        

        if(kilometre<=3){

        printf("小明打车一共花%f",money);

        }else{

             money=k+kilometre+a;

            printf("小明打车一共花%f",money);

        }

        

    }

    return 0;

}


0 回复 有任何疑惑可以回复我~

运行失败

hello.c: In function 'main':

hello.c:6:14: error: stray '\357' in program

     int tax=1;

              ^

hello.c:6:15: error: stray '\274' in program

     int tax=1;

               ^

hello.c:6:16: error: stray '\233' in program

     int tax=1;

                ^

hello.c:7:5: error: expected ',' or ';' before 'int'

     int time;

     ^~~

hello.c:7:13: error: stray '\357' in program

     int time;

             ^

hello.c:7:14: error: stray '\274' in program

     int time;

              ^

hello.c:7:15: error: stray '\233' in program

     int time;

               ^

hello.c:10:12: error: 'time' undeclared (first use in this function)

         if(time>=23&&time<5){

            ^~~~

hello.c:10:12: note: each undeclared identifier is reported only once for each function it appears in

hello.c:11:13: error: 'money' undeclared (first use in this function)

             money=start(kilometre+kilometre*0.2)+tax;

             ^~~~~

hello.c:11:19: error: called object 'start' is not a function or function pointer

             money=start(kilometre+kilometre*0.2)+tax;

                   ^~~~~

hello.c:5:9: note: declared here

     int start=13;

         ^~~~~

hello.c:13:13: error: expected '}' before 'else'

             else{

             ^~~~

hello.c: At top level:

hello.c:26:5: error: expected identifier or '(' before 'return'

     return 0;

     ^~~~~~

hello.c:27:1: error: expected identifier or '(' before '}' token

 }

 ^


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

#include <stdio.h> int main() { int i=12,sum,n=2; if(i<=3) { sum=13; printf("%d",sum); } sum=(i-3)*2.3+sum; for(n=2;n>=1;n--) { sum +=1;} printf("总费用%f",sum); return 0; }

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信