-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5217.cpp
More file actions
50 lines (46 loc) · 949 Bytes
/
5217.cpp
File metadata and controls
50 lines (46 loc) · 949 Bytes
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
// 5217. 쌍의 합
// 2021.05.20
// 구현
#include <iostream>
using namespace std;
int main()
{
int t;
cin >> t;
int n;
while (t-- > 0)
{
cin >> n;
cout << "Pairs for " << n << ": ";
if (n % 2 == 0)
{
for (int i = 1; i < n / 2; i++)
{
if (i == n / 2 - 1)
{
cout << i << " " << n - i;
}
else
{
cout << i << " " << n - i << ", ";
}
}
}
else
{
for (int i = 1; i <= n / 2; i++)
{
if (i == n / 2)
{
cout << i << " " << n - i;
}
else
{
cout << i << " " << n - i << ", ";
}
}
}
cout << endl;
}
return 0;
}