課程
/后端開發(fā)
/C
/C語(yǔ)言入門
為什么算出來(lái)是0
2018-10-18
源自:C語(yǔ)言入門 5-14
正在回答
#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){
? ? ? ? ? ? ?money=k+kilometre+a;
? ? }
? ? return 0;
}
運(yùn)行失敗
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
? ? ? ? ? ? ? ?^
hello.c:6:16: error: stray '\233' in program
? ? ? ? ? ? ? ? ^
hello.c:7:5: error: expected ',' or ';' before 'int'
? ? ?int time;
? ? ?^~~
hello.c:7:13: error: stray '\357' in program
? ? ? ? ? ? ?^
hello.c:7:14: error: stray '\274' in program
hello.c:7:15: error: stray '\233' in program
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
? ? ? ? ? ? ? ? ? ?^~~~~
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
?}
?^
舉報(bào)
C語(yǔ)言入門視頻教程,帶你進(jìn)入編程世界的必修課-C語(yǔ)言
1 回答#include <stdio.h> int main() { int i=0,sum=0; while(i<=100) { sum=sum + i++; printf("100以內(nèi)所有整數(shù)之和為:%d\n",sum); } return 0; }
4 回答#include <stdio.h> #define N 10; int sum(int score[]) { int i,n; for(i=0;i<10;i++) n+=score[i]; printf("%d",n); } int max(int score[]) { int i,ma=0; for(i=0;i<10;i++) { if(score[i]>ma) ma=score[i]; } printf(
1 回答#include <stdio.h> int main() { int year = 2008; int month = 8; int day = 8; int sum=0; switch(month) { case 1:sum=sum+day;break; case 2:sum=sum+day+31;break; case 3:sum=sum+day+31+28;break; case 4:sum=sum+
1 回答int i,sum=0; i=1;為什么不寫成int i=1,sum=0;
3 回答sum+=i 不應(yīng)該等于sum=sum+i 嗎? 為什么是sum=sum+1+2+4.... i=1+2+4.....?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2018-10-29
#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;
}
2018-10-29
運(yùn)行失敗
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
?}
?^