Analysis of the real questions of the Institute of Electronics C/C++ Programming Level Examination in March 2023 (Level 3)

All real questions of C/C++ level exam (Level 1~8)・Click here

Question 1: Sum (2023.3)

Given a sequence of positive integers, determine how many numbers in it 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
Two lines in total, no. One line is the number n of numbers in the sequence (1 <= n <= 100), and the second line is a sequence composed of n positive integers not greater than 10000. Two adjacent integers are separated by a single space. open.
Output
An integer, that is, the number of numbers in the sequence that is equal to the sum of the other two numbers.
Sample input
4
1 2 3 4
Sample output
2

Answer:

//参考答案1:
#include <cstdio>
#include <iostream>

using namespace std;
int a[105];

int main() {
    int 

おすすめ

転載: blog.csdn.net/gozhuyinglong/article/details/134660793