-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1.cpp
58 lines (52 loc) · 833 Bytes
/
1.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
53
54
55
56
57
58
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
//T is # of inputs
int T = 0;
//read from STDIN
cin >> T;
int tempT = T;
int counter = 0;
int inputs[T];
//T array holds N values
while (T){
T--;
cin >> inputs[counter];
counter++;
}
//set counter back to 0
counter = 0;
T = tempT;
//initialize vars
while (counter < T){
int N = inputs[counter];
int high = N/2+1;
int low = N/2;
int k = 0;
//if even
if (N%2==0) {
while (high <= N){
cout << low << " ";
cout << high << " ";
high++;
low--;
}
cout << "\n";
} else {
while (high <= N){
cout << high << " ";
if (low == 0) break;
cout << low << " ";
high++;
low--;
}
cout << "\n";
}
counter++;
}
return 0;
}