求一个输入函数
Calculate a + b.Input
The input will consist of a series of pairs of integers a and b,separated by a space, one pair of integers per line.
Output
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.
以上是题目要求,我写了好久,就是不行,总是错,求帮助啊!
下面是我写的:
#include<stdio.h>
main()
{
struct sum
{
int num1;
int num2;
}stu;
char c;
do
{
printf("Please input a pairs of intagersa and b:\n");
scanf("%d%d",&stu.num1,&stu.num2);
printf("%d\n",stu.num1+stu.num2);
printf("Do you want to continue to input numbers(y/n)?\n");
getchar();
c=getchar();
}
while(c=='y');
return 0;
}
我英语不是太好,你们看看我是不是把题意读错了,谢啦!