March 2022 C/C++ (Level 3) real test analysis#中国电子学院#National Youth Software Programming Level Examination

insert image description here

Problem 1: Sum

Given a sequence of positive integers, determine how many of them are equal to the sum of the other two numbers in the sequence. For example, for the sequence 1 2 3 4, the answer to this question is 2, because 3 = 2 + 1, 4 = 1 + 3.
Time limit: 10000
Memory limit: 65536
Input
a total of two lines, the first line is the number n ( 1 <= n <= 100) of numbers in the sequence, and the second line is a sequence composed of n positive integers not greater than 10000 , separated by a single space between two adjacent integers.
Output
An integer, the number of numbers in the sequence equal to the sum of the other two numbers.
Sample input
4
1 2 3 4
Sample output
2

The following is a program written in C language to determine how many numbers in the sequence are equal to the sum of the other two numbers:

#include <stdio.h>

int cou

Guess you like

Origin blog.csdn.net/gozhuyinglong/article/details/132381401