The topic is very simple!
#include <iostream>using namespacestd;intMain () {inti,j,num[ +],n,count=0; CIN>>N; for(i =0; I < n; i++) {cin>>Num[i]; } for(i =0; I < n; i++) { for(j = i; J < N; j + +) { if(Num[i] + num[j] = =0) Count++; }} cout<< Count <<Endl; return 0;}
Question number: |
201403-1 |
Question Name: |
Opposite number |
Time limit: |
1.0s |
Memory Limit: |
256.0MB |
Problem Description: |
The problem description has N non-0 integers that are not identical. Please make up a program to find out how many pairs of opposite numbers are in them (a and-A are pairs of opposite numbers). The first line of the input format contains a positive integer N. (1≤n≤500). The second behavior N a non-0 integer separated by a single space, the absolute value of each number does not exceed 1000, guaranteeing that the integers are different. The output format only outputs an integer, which is how many pairs of opposite numbers are included in the N number. Sample Input 5 1 2 3-1-2 sample Output 2 |
CCF certification--the opposite number