日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

codeup之A+B 输入输出练习I 、II 、III、IV、V、VI、VII、VIII(黑盒测试

發布時間:2025/5/22 编程问答 35 如意码农
生活随笔 收集整理的這篇文章主要介紹了 codeup之A+B 输入输出练习I 、II 、III、IV、V、VI、VII、VIII(黑盒测试 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

不建議做,掌握書上幾種情況即可,題簡單又重復

I Description

你的任務是計算a+b。這是為了acm初學者專門設計的題目。你肯定發現還有其他題目跟這道題的標題類似,這些問題也都是專門為初學者提供的。

Input

輸入包含一系列的a和b對,通過空格隔開。一對a和b占一行。

Output

對于輸入的每對a和b,你需要依次輸出a、b的和。
如對于輸入中的第二對a和b,在輸出中它們的和應該也在第二行。

Sample Input Copy

1 5
10 20

Sample Output Copy

6
30

solution

#include <stdio.h>
int main(){
int a, b;
while(scanf("%d %d", &a, &b) != EOF)
printf("%d\n", a + b);
return 0;
}

II Description

你的任務是計算a+b。

Input

第一行是一個整數N,表示后面會有N行a和b,通過空格隔開。

Output

對于輸入的每對a和b,你需要在相應的行輸出a、b的和。
如第二對a和b,對應的和也輸出在第二行。

Sample Input Copy

2
1 5
10 20

Sample Output Copy

6
30

solution

#include <stdio.h>
int main(){
int a, b, n;
scanf("%d", &n);
while(n--){
scanf("%d %d", &a, &b);
printf("%d\n", a + b);
} return 0;
}

III Description

你的任務是計算a+b。

Input

輸入中每行是一對a和b。其中會有一對是0和0標志著輸入結束,且這一對不要計算。

Output

對于輸入的每對a和b,你需要在相應的行輸出a、b的和。
如第二對a和b,他們的和也輸出在第二行。

Sample Input Copy

1 5
10 20
0 0

Sample Output Copy

6
30

solution

#include <stdio.h>
int main(){
int a, b;
while(scanf("%d %d", &a, &b), a || b){
printf("%d\n", a + b);
} return 0;
}

IV Description

你的任務是計算若干整數的和。

Input

每行的第一個數N,表示本行后面有N個數。

如果N=0時,表示輸入結束,且這一行不要計算。

Output

對于每一行數據需要在相應的行輸出和。

Sample Input Copy

4 1 2 3 4
5 1 2 3 4 5
0

Sample Output Copy

10
15

solution

#include <stdio.h>
int main(){
int n, sum, x;
while(scanf("%d", &n), n){
sum = 0;
for(int i = 0; i < n; i++){
scanf("%d", &x);
sum += x;
}
printf("%d\n", sum);
} return 0;
}

V Description

你的任務是計算若干整數的和。

Input

輸入的第一行是一個正數N,表示后面有N行。每一行的第一個數是M,表示本行后面還有M個數。

Output

對于每一行數據需要在相應的行輸出和。

Sample Input Copy

2
4 1 2 3 4
5 1 2 3 4 5

Sample Output Copy

10
15

solution

#include <stdio.h>
int main(){
int n, m, sum, x;
scanf("%d", &n);
while(n--){
scanf("%d", &m);
sum = 0;
for(int i = 0; i < m; i++){
scanf("%d", &x);
sum += x;
}
printf("%d\n", sum);
} return 0;
}

VI Description

你的任務是計算若干整數的和。

Input

每行的第一個數N,表示本行后面有N個數。

Output

對于每一行數據需要在相應的行輸出和。

Sample Input Copy

4 1 2 3 4
5 1 2 3 4 5

Sample Output Copy

10
15

solution

#include <stdio.h>
int main(){
int n, sum, x;
while(scanf("%d", &n) != EOF){
sum = 0;
for(int i = 0; i < n; i++){
scanf("%d", &x);
sum += x;
}
printf("%d\n", sum);
} return 0;
}

VII Description

你的任務是計算兩個整數的和。

Input

輸入包含若干行,每行輸入兩個整數a和b,由空格分隔。

Output

對于每組輸入,輸出a和b的和,每行輸出后接一個空行。

Sample Input Copy

1 5
10 20

Sample Output Copy

6

30

solution

#include <stdio.h>
int main(){
int a, b;
while(scanf("%d %d", &a, &b) != EOF){
printf("%d\n\n", a + b);
} return 0;
}

VIII Description

你的任務是計算若干整數的和。

Input

輸入的第一行為一個整數N,接下來N行每行先輸入一個整數M,然后在同一行內輸入M個整數。

Output

對于每組輸入,輸出M個數的和,每組輸出之間輸出一個空行。

Sample Input Copy

3
4 1 2 3 4
5 1 2 3 4 5
3 1 2 3

Sample Output Copy

10

15

6

solution

#include <stdio.h>
int main(){
int n, m, sum, x;
scanf("%d", &n);
while(n--){
scanf("%d", &m);
sum = 0;
for(int i = 0; i < m; i++){
scanf("%d", &x);
sum += x;
}
printf("%d\n\n", sum);
} return 0;
}

總結

以上是生活随笔為你收集整理的codeup之A+B 输入输出练习I 、II 、III、IV、V、VI、VII、VIII(黑盒测试的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。