不建议做,掌握书上几种情况即可,题简单又重复

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(黑盒测试的更多相关文章

  1. 买卖股票的最佳时机I II III IV

    I 假设有一个数组,它的第i个元素是一支给定的股票在第i天的价格.如果你最多只允许完成一次交易(例如,一次买卖股票),设计一个算法来找出最大利润. II 假设有一个数组,它的第i个元素是一个给定的股票 ...

  2. hdu 3081 hdu 3277 hdu 3416 Marriage Match II III IV //灵活运用最大流量

    3081 意甲冠军: n女生选择不吵架,他甚至男孩边(他的朋友也算.并为您收集过程).2二分图,一些副作用,有几个追求完美搭配(每场比赛没有重复的每一个点的比赛) 后.每次增广一单位,(一次完美匹配) ...

  3. LeetCode之“动态规划”:Best Time to Buy and Sell Stock I && II && III && IV

    Best Time to Buy and Sell Stock I 题目链接 题目要求: Say you have an array for which the ith element is the ...

  4. combination sum(I, II, III, IV)

    II 简单dfs vector<vector<int>> combinationSum2(vector<int>& candidates, int targ ...

  5. Two Sum I & II & III & IV

    Two Sum I Given an array of integers, find two numbers such that they add up to a specific target nu ...

  6. hdu 3081 hdu 3277 hdu 3416 Marriage Match II III IV //最大流的灵活运用

    3081 题意: n个女孩选择没有与自己吵过架的男孩有连边(自己的朋友也算,并查集处理),2分图,有些边,求有几种完美匹配(每次匹配每个点都不重复匹配) 我是建二分图后,每次增广一单位,(一次完美匹配 ...

  7. Best Time to Buy and Sell Stock I II III IV

    一.Best Time to Buy and Sell Stock I Say you have an array for which the ith element is the price of ...

  8. Leetcode 137. Single Number I/II/III

    Given an array of integers, every element appears twice except for one. Find that single one. 本题利用XO ...

  9. LeetCode Single Number I / II / III

    [1]LeetCode 136 Single Number 题意:奇数个数,其中除了一个数只出现一次外,其他数都是成对出现,比如1,2,2,3,3...,求出该单个数. 解法:容易想到异或的性质,两个 ...

  10. 1. Two Sum I & II & III

    1. Given an array of integers, return indices of the two numbers such that they add up to a specific ...

随机推荐

  1. clickhouse--表引擎

    表引擎 表引擎(即表的类型)决定了: 1)数据的存储方式和位置,写到哪里以及从哪里读取数据 2)支持哪些查询以及如何支持. 3)并发数据访问. 4)索引的使用(如果存在). 5)是否可以执行多线程请求 ...

  2. 【多进程并发笔记】Python-Multiprocess

    目录 调用函数后,函数内的变量如何释放? python2.7怎么使用多线程加速for loop 多进程进程池,函数序列化错误的处理 Time模块计算程序运行时间 使用多进程,Start()后,如何获得 ...

  3. python excel 读取:如何读取符合多个条件的记录【出差、外出、调休、年假】

    if 语句结合or 实现:读取所有出差.外出.调休.年假的记录 if '出差' in str(c_cell) or '外出' in str(c_cell) or'调休' in str(c_cell) ...

  4. Oracle12c 数据库 警告日志

    目录 一:查看警告日志文件的位置 二:警告日志内容 三:告警日志监控: 方案1: 方案2: 方案3: 正文 回到顶部 一:查看警告日志文件的位置 Oracle 12c环境下查询,alert日志并不在b ...

  5. CentOS 版本选择DVD、Everything、LiveCD、Minimal、NetInstall

    CentOS 7.X,主要是下载的时候有很多版本供选择,如何选择? DVD版:这个是常用版本,就是普通安装版了,推荐大家安装.里面包含大量的常用软件,大部分情况下安装时无需再在线下载,体积为4G.Ev ...

  6. CSAPP学习笔记——chapter9 虚拟内存

    CSAPP学习笔记--chapter9 虚拟内存 虚拟内存提供三个重要的功能.第一,它在主存中自动缓存最近使用的存放磁盘上的虚拟地址空间的内容.虚拟内存缓存中的块叫做页.对磁盘上页的引用会触发缺页,缺 ...

  7. study Rust-2【环境与配置,随机数】

    Rust教程资料很多.但是,这是教程学习资料感觉挺好!推荐给你https://doc.rust-lang.org/stable/book/ (简体中文译本)在线阅读 学习rust开始有点感觉了.美好的 ...

  8. 活动中台系统慢 SQL 治理实践

    作者:vivo 互联网服务器团队- Zhang Mengtao 活动中台系统作为中台项目非常注重系统性能和用户体验,数据库系统性能问题会对应用程序的性能和用户体验产生负面影响.慢查询可能导致应用程序响 ...

  9. sql连接处理

    序言 数据存储是一个很重要的话题,小到C里面的struct,到os的一个个数据表,大到一个个数据库软件乃至单纯提供数据存储和访问服务的集群,提供数据的快速访问.持久化维护.崩坏数据的恢复,数据的加密维 ...

  10. FastAPI依赖覆盖与测试环境模拟

    title: FastAPI依赖覆盖与测试环境模拟 date: 2025/04/10 00:58:09 updated: 2025/04/10 00:58:09 author: cmdragon ex ...