1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-12-16 15:44:39 +00:00
202401-programming-assignments/【实践课外】3.选择结构2/7-1 选择-奇数平方和.c

53 lines
860 B
C

#include <stdio.h>
int main() {
int a, b, c, d, e;
int ans_odd = 0, ans_even = 0;
scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
if (a % 2 == 0) {
ans_even += a * a;
} else {
ans_odd += a * a;
}
if (b % 2 == 0) {
ans_even += b * b;
} else {
ans_odd += b * b;
}
if (c % 2 == 0) {
ans_even += c * c;
} else {
ans_odd += c * c;
}
if (d % 2 == 0) {
ans_even += d * d;
} else {
ans_odd += d * d;
}
if (e % 2 == 0) {
ans_even += e * e;
} else {
ans_odd += e * e;
}
if (ans_odd == 0) {
printf("No Odd Number\n");
} else {
printf("%d\n", ans_odd);
}
if (ans_even == 0) {
printf("No Even Number\n");
} else {
printf("%d\n", ans_even);
}
return 0;
}