标签:
试题编号: 201403-1
时间限制: 1.0s
内存限制: 256.0MB
解题思路:
代码(java):
1 package ccf_test2014_03; 2 3 import java.util.Scanner; 4 5 public class Opposite { 6 7 final static int MAX = 1000; 8 9 public static void main(String[] args) { 10 11 int[] shuju = new int[MAX]; 12 13 Scanner input = new Scanner(System.in); 14 15 int n = input.nextInt(); 16 17 input.nextLine(); 18 19 int result = 0; 20 21 for(int i = 0; i < n; i++){ 22 23 int num = input.nextInt(); 24 25 num = Math.abs(num); 26 27 shuju[num]++; 28 29 if(shuju[num]>1){ 30 31 result++; 32 } 33 } 34 System.out.println(result); 35 } 36 }
结果:
标签:
原文地址:http://www.cnblogs.com/haimishasha/p/5327229.html