代碼作用:計算兩數和差積商余數雖然沒有錯誤但是運行出來沒有運算結果
#include <stdio.h>
int main()
{
//input
printf("請依次輸入兩數:");
int a,b;
//output
long int x,y,z,n;
double m;
scanf("%d%d",a,b);
x=a+b;
y=a-b;
z=a*b;
m=a/b;
n=a%b;
printf("x=%d\ny=%d\nz=%d\nm=%lf\nn=%d\n",x,y,z,m,n);
return 0;
}
錯誤報告:
||=== Build: Debug 在 2 中 (編譯器: GNU GCC Compiler) ===|
xiao\Desktop\codeblock\2\main.c||In function 'main':|
xiao\Desktop\codeblock\2\main.c|153|warning: format '%d' expects type 'int *', but argument 2 has type 'int'|
xiao\Desktop\codeblock\2\main.c|153|warning: format '%d' expects type 'int *', but argument 3 has type 'int'|
xiao\Desktop\codeblock\2\main.c|159|warning: format '%d' expects type 'int', but argument 2 has type 'long int'|
xiao\Desktop\codeblock\2\main.c|159|warning: format '%d' expects type 'int', but argument 3 has type 'long int'|
xiao\Desktop\codeblock\2\main.c|159|warning: format '%d' expects type 'int', but argument 4 has type 'long int'|
xiao\Desktop\codeblock\2\main.c|159|warning: format '%d' expects type 'int', but argument 6 has type 'long int'|
xiao\Desktop\codeblock\2\main.c|153|warning: 'a' is used uninitialized in this function|
xiao\Desktop\codeblock\2\main.c|153|warning: 'b' is used uninitialized in this function|
||=== 構建 finished: 0 error(s), 8 warning(s) (0 分, 1 秒) ===|
新人第一次發帖有哪里做錯請指出來謝謝
uj5u.com熱心網友回復:
供參考:#include <stdio.h>
int main()
{
//input
printf("請依次輸入兩數:");
int a,b;
//output
long int x,y,z,n;
double m;
scanf("%d%d",&a,&b); //scanf("%d%d",a,b);
x=a+b;
y=a-b;
z=a*b;
m=1.0*a/b; //m=a/b;
n=a%b;
printf("x=%d\ny=%d\nz=%d\nm=%lf\nn=%d\n",x,y,z,m,n);
return 0;
}
uj5u.com熱心網友回復:
C語言是函式都是傳值,就是復制粘貼,所以要想修改函式的引數,需要傳地址轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/267528.html
標籤:新手樂園
上一篇:求助!紅蜘蛛反抗程式撰寫教程
