一道简单的英文述题的C语言编程题.要求答案思路精确.
来源:学生作业帮 编辑:搜搜做题作业网作业帮 分类:综合作业 时间:2024/08/07 05:41:56
一道简单的英文述题的C语言编程题.要求答案思路精确.
The first line integer means the number of input integer a and b.Your task is to Calculate a + b.
输入
Your task is to Calculate a + b.The first line integer means the numbers of pairs of input integers.
输出
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.
样例输入
2
1 5
10 20
样例输出
6
30
The first line integer means the number of input integer a and b.Your task is to Calculate a + b.
输入
Your task is to Calculate a + b.The first line integer means the numbers of pairs of input integers.
输出
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.
样例输入
2
1 5
10 20
样例输出
6
30
![一道简单的英文述题的C语言编程题.要求答案思路精确.](/uploads/image/z/12125613-21-3.jpg?t=%E4%B8%80%E9%81%93%E7%AE%80%E5%8D%95%E7%9A%84%E8%8B%B1%E6%96%87%E8%BF%B0%E9%A2%98%E7%9A%84C%E8%AF%AD%E8%A8%80%E7%BC%96%E7%A8%8B%E9%A2%98.%E8%A6%81%E6%B1%82%E7%AD%94%E6%A1%88%E6%80%9D%E8%B7%AF%E7%B2%BE%E7%A1%AE.)
首先要把题目看明白.
第一行的输入是指要输入a和b的对数,从第二行开始,每一行就是一对a,b,你的任务是计算a+b的结果,并在最后输出出来.
我定义1个整形变量n用来保存第一个输入,然后用它动态生成一个数组,用这个数组来保存每一行a+b的值,代码如下:
int main()
{
int n;
cin>>n;
int x,y;
int *p=new int[n];
for(int i=0;i>x>>y;
p[i]=x+y;
}
for(int i=0;i
第一行的输入是指要输入a和b的对数,从第二行开始,每一行就是一对a,b,你的任务是计算a+b的结果,并在最后输出出来.
我定义1个整形变量n用来保存第一个输入,然后用它动态生成一个数组,用这个数组来保存每一行a+b的值,代码如下:
int main()
{
int n;
cin>>n;
int x,y;
int *p=new int[n];
for(int i=0;i>x>>y;
p[i]=x+y;
}
for(int i=0;i