C++读入两个参数

题目内容:编写程序计算两个整数的差。

输入描述:输入数据含有不超过50个整数对,每个整数队及每对整数的运算结果都不会超过231或-231。

输出描述:对于每次读入的一对整数,输出前者减去后者的差。每个结果以回车结束。

代码示例:

#include "stdafx.h"
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
struct Discrepancy
{
	int minuend;
	int subtrahend;
};

int main(int argc, char * argv[])
{
	vector<Discrepancy> d(50);
	int num = 0;
	int m, s;
	while (num <= 49)
	{
		scanf_s("%d%d",&m,&s);
		d[num].minuend = m;
		d[num].subtrahend = s;
		cout << m - s<<endl;
		num++;
	}
	return 0;
}
posted @ 2013-10-20 22:02  源子陌  Views(471)  Comments(0Edit  收藏  举报