题解 | #数字求和#
数字求和
https://www.nowcoder.com/practice/e8cee01f2d834fa9ba3479fafe492b65
#include <stdio.h> int main(){ //输入 int num; int arr[5]; while (scanf("%d", &num) != EOF) { for (int i = 0; i < 5; ++i) { scanf("%d", &arr[i]); } //判断并累加 int sum = 0; for (int i = 0; i < 5; ++i) { if (arr[i] < num) { sum += arr[i]; } } printf("%d\n", sum); } return 0; }