diff --git a/【实践课外】3.选择结构2/7-1 选择-奇数平方和.c b/【实践课外】3.选择结构2/7-1 选择-奇数平方和.c new file mode 100644 index 0000000..92cf6fa --- /dev/null +++ b/【实践课外】3.选择结构2/7-1 选择-奇数平方和.c @@ -0,0 +1,52 @@ +#include + +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; +} diff --git a/【实践课外】3.选择结构2/7-1 选择-奇数平方和.jpg b/【实践课外】3.选择结构2/7-1 选择-奇数平方和.jpg new file mode 100644 index 0000000..3116ea1 Binary files /dev/null and b/【实践课外】3.选择结构2/7-1 选择-奇数平方和.jpg differ diff --git a/【实践课外】3.选择结构2/7-2 选择-外卖.c b/【实践课外】3.选择结构2/7-2 选择-外卖.c new file mode 100644 index 0000000..6c782f5 --- /dev/null +++ b/【实践课外】3.选择结构2/7-2 选择-外卖.c @@ -0,0 +1,18 @@ +#include +#include + +int main() { + double x, y; + + scanf("%lf%lf", &x, &y); + + if (x <= 0 && y >= 0 || x <= y && y <= 0) { + printf("\\^O^/\n"); + } else if (x > y && y <= 0) { // 类似 -0.5 -0.75 的情况 + printf("1\n"); + } else { + printf("%d\n", (int)ceil(y / x)); + } + + return 0; +} diff --git a/【实践课外】3.选择结构2/7-2 选择-外卖.jpg b/【实践课外】3.选择结构2/7-2 选择-外卖.jpg new file mode 100644 index 0000000..266b345 Binary files /dev/null and b/【实践课外】3.选择结构2/7-2 选择-外卖.jpg differ diff --git a/【实践课外】3.选择结构2/7-3 选择-糖果.c b/【实践课外】3.选择结构2/7-3 选择-糖果.c new file mode 100644 index 0000000..17e46a8 --- /dev/null +++ b/【实践课外】3.选择结构2/7-3 选择-糖果.c @@ -0,0 +1,15 @@ +#include + +int main() { + int n, m; + + scanf("%d%d", &n, &m); + + if (n >= m + 1 && n % (m + 1) == 0) { + printf("Second win\n"); + } else { + printf("First win\n"); + } + + return 0; +} diff --git a/【实践课外】3.选择结构2/7-3 选择-糖果.jpg b/【实践课外】3.选择结构2/7-3 选择-糖果.jpg new file mode 100644 index 0000000..02036fc Binary files /dev/null and b/【实践课外】3.选择结构2/7-3 选择-糖果.jpg differ diff --git a/【实践课外】3.选择结构2/7-4 C程序设计 实验2-2-2成绩转换(switch).c b/【实践课外】3.选择结构2/7-4 C程序设计 实验2-2-2成绩转换(switch).c new file mode 100644 index 0000000..7b5e2e3 --- /dev/null +++ b/【实践课外】3.选择结构2/7-4 C程序设计 实验2-2-2成绩转换(switch).c @@ -0,0 +1,36 @@ +#include + +int main() { + int score; + + scanf("%d", &score); + + switch (score / 10) { + case 10: + case 9: + printf("A\n"); + break; + case 8: + printf("B\n"); + break; + case 7: + printf("C\n"); + break; + case 6: + printf("D\n"); + break; + case 5: + case 4: + case 3: + case 2: + case 1: + case 0: + printf("E\n"); + break; + default: + printf("Input error!\n"); + break; + } + + return 0; +} diff --git a/【实践课外】3.选择结构2/7-4 C程序设计 实验2-2-2成绩转换(switch).jpg b/【实践课外】3.选择结构2/7-4 C程序设计 实验2-2-2成绩转换(switch).jpg new file mode 100644 index 0000000..4814086 Binary files /dev/null and b/【实践课外】3.选择结构2/7-4 C程序设计 实验2-2-2成绩转换(switch).jpg differ diff --git a/【实践课外】3.选择结构2/7-5 选择-我是特种兵.c b/【实践课外】3.选择结构2/7-5 选择-我是特种兵.c new file mode 100644 index 0000000..2afcc5d --- /dev/null +++ b/【实践课外】3.选择结构2/7-5 选择-我是特种兵.c @@ -0,0 +1,19 @@ +#include + +int main() { + int x1, y1, x2, y2, x3, y3; + + scanf("%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &x3, &y3); + + int d1 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2); + int d2 = (x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3); + int d3 = (x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3); + + if (d1 + d2 == d3) { + printf("yes\n"); + } else { + printf("no\n"); + } + + return 0; +} diff --git a/【实践课外】3.选择结构2/7-5 选择-我是特种兵.jpg b/【实践课外】3.选择结构2/7-5 选择-我是特种兵.jpg new file mode 100644 index 0000000..479c26a Binary files /dev/null and b/【实践课外】3.选择结构2/7-5 选择-我是特种兵.jpg differ diff --git a/【实践课外】3.选择结构2/7-6 选择-奖学金.c b/【实践课外】3.选择结构2/7-6 选择-奖学金.c new file mode 100644 index 0000000..364f483 --- /dev/null +++ b/【实践课外】3.选择结构2/7-6 选择-奖学金.c @@ -0,0 +1,32 @@ +#include + +int main() { + int id, avg_score, dis_score, is_cadre, paper_num; + int ans = 0; + + scanf("%d%d%d%d%d", &id, &avg_score, &dis_score, &is_cadre, &paper_num); + + // 院士奖学金 + if (avg_score > 80 && paper_num >= 1) { + ans += 8000; + } + + // 五四奖学金 + if (avg_score > 85 && dis_score > 80) { + ans += 4000; + } + + // 成绩优秀奖 + if (avg_score > 90) { + ans += 2000; + } + + // 班级贡献奖 + if (dis_score > 80 && is_cadre) { + ans += 850; + } + + printf("%d\n", ans); + + return 0; +} diff --git a/【实践课外】3.选择结构2/7-6 选择-奖学金.jpg b/【实践课外】3.选择结构2/7-6 选择-奖学金.jpg new file mode 100644 index 0000000..228fe41 Binary files /dev/null and b/【实践课外】3.选择结构2/7-6 选择-奖学金.jpg differ diff --git a/【实践课外】3.选择结构2/7-7 选择-K线图.c b/【实践课外】3.选择结构2/7-7 选择-K线图.c new file mode 100644 index 0000000..d548e6b --- /dev/null +++ b/【实践课外】3.选择结构2/7-7 选择-K线图.c @@ -0,0 +1,29 @@ +#include + +int main() { + double open, high, low, close; + + scanf("%lf%lf%lf%lf", &open, &high, &low, &close); + + if (close < open) { + printf("BW-Solid"); + } else if (close > open) { + printf("R-Hollow"); + } else { + printf("R-Cross"); + } + + if (low < open && low < close || high > open && high > close) { + printf(" with "); + + if (low < open && low < close && high > open && high > close) { + printf("Lower Shadow and Upper Shadow"); + } else if (low < open && low < close) { + printf("Lower Shadow"); + } else { // high > open && high > close + printf("Upper Shadow"); + } + } + + return 0; +} diff --git a/【实践课外】3.选择结构2/7-7 选择-K线图.jpg b/【实践课外】3.选择结构2/7-7 选择-K线图.jpg new file mode 100644 index 0000000..748cc01 Binary files /dev/null and b/【实践课外】3.选择结构2/7-7 选择-K线图.jpg differ