-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10812.cpp
52 lines (34 loc) · 996 Bytes
/
10812.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <cstdio>
using namespace std;
int main ()
{
int iCase; //宣告輸入的測組
while( true )
{
int iTeam1; //宣告第一個隊伍
int iTeam2; //宣告第二個隊伍
int iSum; //宣告兩對的和
int iDifference; //宣告兩對的差
cin >> iCase; //輸入測組
for (int i = 1 ; i <= iCase ; i++ )
{
cin >> iTeam1 >> iTeam2; //輸入兩隊的分數
//若iTeam1 大於 iTeam2時 印出和與差
if ( iTeam1 > iTeam2 )
{
//兩對分數相加除以2
iSum = ( iTeam1 + iTeam2 ) / 2;
//兩隊分數相減除以2
iDifference = ( iTeam1 - iTeam2 ) / 2;
//印出和與差
cout << iSum << " " << iDifference << '\n';
}
//若不是則印出impossible
else
{
cout << "impossible" << '\n';
}
}
}
}