急求!!用C语言怎么做??
来源:百度知道 编辑:UC知道 时间:2024/06/11 22:05:21
Problem Description
Your task is to 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, and followed by a blank line.
Sample Input
1 5
10 20
Sample Output
6
30
Your task is to 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, and followed by a blank line.
Sample Input
1 5
10 20
Sample Output
6
30
我不知道你是干什么的,要是一个计算机从业者或是计算机学习爱好者的话
连这个你都不会就干点别的吧你不适合计算机
#include <stdio.h>
int main()
{
FILE* pInput = fopen( "input.txt", "r" );
if( NULL == pInput )
{
printf( "open inputfile Error!" );
return -1;
}
FILE* pOutput = fopen( "output.txt", "w" );
if( NULL == pOutput )
{
fclose( pInput );
printf( "open outputfile Error!" );
return -1;
}
while( !feof( pInput ) )
{
int iNum1 = 0;
int iNum2 = 0;
fscanf( pInput, "%d %d", &iNum1, &iNum2 );
fprintf( pOutput, "%d\n\n", iNum1 + iNum2 );
}
fclose( pOutput );
fclose( pInput );
return 0;
}