CSP201403-1: reverse number, csp201403-1 reverse number
Introduction:CSPHttp://www.cspro.org/lead/application/ccf/login.jsp)YesbyCCFThe "Computer vocational qualification certification" examination is initiated to authenticate the competence of professionals in computer software development, software testing, information management, and other fields. The authenticated object is engaged in or will be engaged in ITSpecialized technical and technical management personnel in the field, as well as review objects for university candidates.
There are N non-zero and different integers. Compile a program to find the number of pairs of the opposite numbers (a and-a are a pair of opposite numbers ).
The first line contains a positive integer N. (1≤n ≤500 ).
The second behavior is N non-zero integers separated by a single space. The absolute value of each number cannot exceed 1000, so that these integers are different.
Only one integer is output, that is, the number of pairs in the N number.
5
1 2 3-1-2
2
1 # include <stdio. h> 2 # include <stdlib. h> 3 # include <memory. h> 4 5 int main (void) 6 {7 int n; // Number of 8 scanf ("% d", & n); 9 10 int result = 0; 11 int * input = (int *) malloc (sizeof (int) * n); 12 memset (input, 0, sizeof (int) * n ); 13 14 for (int I = 0; I <n; I ++) 15 {16 scanf ("% d", input + I ); 17} 18 19 for (int I = 0; I <n; I ++) 20 {21 for (int j = I + 1; j <n; j ++) 22 {23 if (input [I] + input [j] = 0) 24 {25 result + = 1; 26} 27} 28} 29 30 printf ("% d \ n", result); 31 free (input); 32 return 0; 33}