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

insert image description here

Problem 1: Find two elements whose sum is K

In an integer sequence of length n (n < 1000), determine whether there are two elements whose sum is k.
Input
The lengths n and k of the input sequence on the first line, separated by spaces. The second line enters n integers in the sequence, separated by spaces.
Output
If the sum of some two elements is k, output yes, otherwise output no.
Sample input
9 10
1 2 3 4 5 6 7 8 9
Sample output
yes

Here is an example of C language code that solves the problem:

#include <stdio.h>

int checkSum(int arr[]

Guess you like

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