-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
46 lines (37 loc) · 736 Bytes
/
Main.java
File metadata and controls
46 lines (37 loc) · 736 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
import java.util.*;
import java.net.*;
import java.io.*;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int testCase = scan.nextInt();
while(testCase >= 1) {
int a = scan.nextInt();
String s = scan.next();
int result = 0;
for(int i = 0; i < a; i++) {
if(s.charAt(i) == '+') {
result += 1;
}
if(s.charAt(i) == '-') {
result += -1;
}
}
if(result < 0) {
result *= (-1);
}
System.out.println(result);
testCase--;
}
scan.close();
}
static void println(Object o) {
System.out.println(o);
}
static void printNumArr2D(int[] n) {
for(var t : n) {
System.out.print(t+" ");
}
System.out.println();
}
}