1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-12-03 17:26:21 +00:00
202401-programming-assignments/【实践课内】4.循环结构1/7-1 求奇数和.c

16 lines
198 B
C
Raw Normal View History

2024-10-25 08:00:36 +00:00
#include <stdio.h>
int main() {
int x, ans = 0;
while (scanf("%d", &x), x > 0) {
if (x % 2 == 1) {
ans += x;
}
}
printf("%d\n", ans);
return 0;
}