目录
7-219 sdut-C语言实验-A+B for Input-Output Practice (不确定次数循环)
7-219 sdut-C语言实验-A+B for Input-Output Practice (不确定次数循环)
分数 10
全屏浏览题目
切换布局
作者 马新娟
单位 山东理工大学
Your task is to Calculate a + b.
Too easy?! Of course! I specially designed the problem for acm beginners.
You must have found that some problems have the same titles with this one, yes, all these problems were designed for the same aim.
输入格式:
The input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line.
输出格式:
For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.
输入样例:
1 5
10 20
输出样例:
在这里给出相应的输出。例如:
6
30
代码如下:
#include "stdio.h"
int a,b;
int main()
{
while(scanf("%d%d",&a,&b)!= EOF)
{
printf("%d\n",a+b);
}
}
7-220 sdut-C语言实验——两个数比较
分数 10
全屏浏览题目
切换布局
作者 马新娟
单位 山东理工大学
求2个数中较大者。
输入格式:
第一行为测试的数据组数N,接下来的N行分别是两个待比较的整数。
输出格式:
输出N行,每一行的值为每组数中较大的整数。
输入样例:
2
1 2
15 10
输出样例:
在这里给出相应的输出。例如:
2
15
代码如下:
#include <stdio.h>
int main(){
int a;
int x,y;
scanf("%d",&a);
for(int i = 0; i < a; i++){
scanf("%d%d",&x,&y);
x > y? printf("%d\n",x):printf("%d\n",y);
}
return 0;
}