CSP201403-1: reverse number, csp201403-1 reverse number

Source: Internet
Author: User

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.

 

  • Problem description

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 ).

  • Input Format

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.

  • Output Format

Only one integer is output, that is, the number of pairs in the N number.

  • Sample Input

5

1 2 3-1-2

  • Sample output

2

 

  • Source code

 

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}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.