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

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. 关于centos 7安装binwalk的过程中产生的问题

    啊,kali机坏了,又安的centos o(╥﹏╥)o 但是centos没有binwalk,它也不能像kali机一样之间install 又在网上搜教程 https://blog.csdn.net/qq ...

  2. Caused by: java.lang.IllegalArgumentException: invalid comparison: java.util.Date and java.lang.String 解决办法

    使用MyBatis 更新数据库数据的时候 遇到了这个错误: Caused by: java.lang.IllegalArgumentException: invalid comparison: jav ...

  3. uniapp vue3 setup + 云开发开发个人小程序

    最近使用uniapp vue3 setup + 云开发开发了个人小程序,设计使用figma软件,看下成品截图吧(可以直接微信搜索[识光]小程序体验,或者最底部有码可以直接扫)

  4. 关闭windows计划重启

    前言 windows 总是自动计划更新 解决方案 需要禁用服务 "Windows Update" 和 "更新 Orchestrator 服务" 首先去这里下载P ...

  5. Linux系统挂载未分配硬盘空间

    先查看未挂载之前的磁盘使用情况 发现磁盘使用率已经达到了96%,迫切需要扩容 查看分区情况fdisk –l 首先确保有可分配的磁盘空间 发现/dev/vda下有400多个G 的空间 所以将/dev/v ...

  6. PLSQL中查询数据的时候查询结果显示中文乱码

    要需要很努力才能看起来毫不费力.....1.在PLSQL中查询数据的时候查询结果显示中文乱码这里写图片描述2.需要在环境变量中新建两个环境变量:第一个:设置 NLS_LANG=SIMPLIFIED C ...

  7. 一个基于 .NET 开源免费的异地组网和内网穿透工具

    前言 今天大姚给大家分享一个基于 .NET 开源免费的异地组网和内网穿透工具:linker. 工具介绍 linker是一个基于 .NET8 开源免费(GPL-2.0 license)的异地组网和内网穿 ...

  8. Cannot attach the file *.mdf as database

    使用ASP.NET MVC 4 和 Entity Framwork 6(Code First)爬的一个坑,无意间把App_Data下的*.mdf文件删除了,然后程序编译正常,但是运行异常RT,留爪. ...

  9. ASP.NET Core 响应压缩中间件

    使用及对比 在 Startup.cs 中添加服务并使用即可,主代码如下: // Startup.cs public void ConfigureServices(IServiceCollection ...

  10. leetcode每日一题:对角线上不同值的数量差

    题目 2711. 对角线上不同值的数量差 给你一个下标从 0 开始.大小为 m x n 的二维矩阵 grid ,请你求解大小同样为 m x n 的答案矩阵 answer . 矩阵 answer 中每个 ...