A. Bit++
Solution :
import java.util.Scanner;
public class Bitplusplus {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int no = 0;
int test = sc.nextInt();
sc.nextLine();
while (test-->0) {
String s = sc.nextLine();
if(s.equals("X++"))
no++;
if(s.equals("++X"))
no++;
if(s.equals("X--"))
no--;
if(s.equals("--X"))
no--;
}
System.out.println(no);
sc.close();
}
}
0 comments:
Do not spam here.