Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //03 정수 연산
- #include <iostream>
- #include <fstream>
- #include <cstdlib>
- using namespace std;
- void main()
- {
- ifstream inStream;
- int numTestCases;
- inStream.open("input.txt"); // open input file
- if (inStream.fail())
- {
- cerr << "Input file opening failed.\n";
- exit(1);
- }
- inStream >> numTestCases; // read the number of test cases
- for (int i = 0; i < numTestCases; i++)
- {
- int a, b;
- int sum, diff, mul, div, mod, abs, upper, same;
- inStream >> a >> b;
- sum = a + b;
- diff = a - b;
- mul = a*b;
- div = a / b;
- mod = a%b;
- if (a > b)
- {
- abs = a - b;
- upper = a;
- }
- else
- {
- abs = b - a;
- upper = b;
- }
- if (a == b)
- {
- same = 1;
- }
- else
- {
- same = 0;
- }
- cout << sum << ' ' << diff << ' ' << abs << ' ';
- cout << mul << ' ' << div << ' ' << mod << ' '<<upper<<' '<< same<<' '<<endl;
- }
- inStream.close(); //close input file
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement