CCF certification--the opposite number

Source: Internet
Author: User

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

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.