Fork me on GitHub

NYOJ题目1049自增自减

---------------------------------

简单的字符判断。

 

AC代码:

 1 import java.util.Scanner;
 2 
 3 public class Main {
 4 
 5     public static void main(String[] args) {
 6         
 7         Scanner sc=new Scanner(System.in);
 8         
 9         int times=Integer.parseInt(sc.nextLine());
10         while(times-->0){
11             int ans=0;
12             int n=Integer.parseInt(sc.nextLine());
13             while(n-->0){
14                 if(sc.nextLine().indexOf("+")!=-1){
15                     ans++;
16                 }else{
17                     ans--;
18                 }
19             }
20             System.out.println(ans);
21         }
22         
23     }
24     
25 }

 

题目来源: http://acm.nyist.net/JudgeOnline/problem.php?pid=1049

posted @ 2016-09-15 23:48  CC11001100  阅读(179)  评论(0编辑  收藏  举报