修改 node_modules 中扩展包的源码

ping 百度 :未知的服务或名称

  返回  

[Java] HJ94 记票统计

2021/8/20 17:18:41 浏览:
  • 原题
import java.io.*;
import java.util.*;

public class Main {
    public static void main (String [] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

        String line = null;
        while ((line = f.readLine()) != null)
        {
            int n = Integer.parseInt(line);
            // 这里需要保存名字,因为需要按名字顺序打印
            String[] names = new String[n];
            StringTokenizer st = new StringTokenizer(f.readLine());
            for (int i = 0; i < n; i++)
            {
                names[i] = st.nextToken();
            }
            // n个候选人的名字
            Map<String, Integer> map = new HashMap<>();
            for (String name : names) {
                map.put(name, 0);
            }
            
            int invalid = 0;
            // m个投票人
            int m = Integer.parseInt(f.readLine());
            st = new StringTokenizer(f.readLine());
            for (int i = 0; i < m; i++) 
            {
                String name = st.nextToken();
                if (map.containsKey(name)) {
                    map.put(name, map.get(name) + 1);
                }
                else {
                    invalid++;
                }
            }
            for (String name : names) {
                out.println(name  + " : " + map.get(name));
            }
            out.println("Invalid : " + invalid);
        }
        out.close();
        f.close();
    }
}

联系我们

如果您对我们的服务有兴趣,请及时和我们联系!

服务热线:18288888888
座机:18288888888
传真:
邮箱:888888@qq.com
地址:郑州市文化路红专路93号