-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDivPer.java
More file actions
24 lines (24 loc) · 747 Bytes
/
DivPer.java
File metadata and controls
24 lines (24 loc) · 747 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
import java.util.Scanner;
public class DivPer {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
if (sc.hasNextInt()) {
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int curr = (n + 1) / 2;
StringBuilder out = new StringBuilder();
out.append(curr);
for (int i = 1; i < n; i++) {
if (i % 2 != 0) {
curr += i;
} else {
curr -= i;
}
out.append(" ").append(curr);
}
System.out.println(out);
}
}
}
}