#include <iostream>using namespace std;int main(){int a,b,c;cin>>a>>b>>c;cout<<"a+b+c";return 0;}這個(gè)程序,我運(yùn)行時(shí)輸入 11 22 33結(jié)果卻還是a+b+c而不是11+22+33的值66
3 回答

Qyouu
TA貢獻(xiàn)1786條經(jīng)驗(yàn) 獲得超11個(gè)贊
C++中實(shí)現(xiàn)a+b+c求和的方法有二種,分別如下:
方法1,把三個(gè)數(shù)加起來(lái),賦給d, 把 d 打印出來(lái)。
1 2 3 4 5 6 7 8 9 10 | #include <stdio.h> #include <stdlib.h> main(){ int a,b,c,d; printf("please input a b c:\n"); scanf("%d %d %d",&a,&b,&c); d = a+b+c; printf("%d\n",d); return 0; } |
方法2,直接打印 表達(dá)式 a+b+c 的值。
1 2 3 4 5 6 7 8 9 | #include <stdio.h> #include <stdlib.h> main(){ int a,b,c,d; printf("please input a b c:\n"); scanf("%d %d %d",&a,&b,&c); printf("%d\n",a+b+c); return 0; } |
- 3 回答
- 0 關(guān)注
- 598 瀏覽
添加回答
舉報(bào)
0/150
提交
取消