mirror of
https://github.com/renbaoshuo/202401-programming-assignments.git
synced 2024-11-27 08:26:20 +00:00
增加 25e3fb1d
的 C 语言代码
This commit is contained in:
parent
25e3fb1d7c
commit
1e0c23a743
9
【实践课外】0.熟悉编程环境/7-1 重要的话说三遍.c
Normal file
9
【实践课外】0.熟悉编程环境/7-1 重要的话说三遍.c
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
printf("I'm gonna WIN!\n");
|
||||||
|
printf("I'm gonna WIN!\n");
|
||||||
|
printf("I'm gonna WIN!\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
12
【实践课外】0.熟悉编程环境/7-2 计算平均分.c
Normal file
12
【实践课外】0.熟悉编程环境/7-2 计算平均分.c
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int math = 87;
|
||||||
|
int eng = 72;
|
||||||
|
int comp = 93;
|
||||||
|
int average = (math + eng + comp) / 3;
|
||||||
|
|
||||||
|
printf("math = %d, eng = %d, comp = %d, average = %d\n", math, eng, comp, average);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
12
【实践课外】0.熟悉编程环境/7-3 计算长方形的周长和面积.c
Normal file
12
【实践课外】0.熟悉编程环境/7-3 计算长方形的周长和面积.c
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int a, b;
|
||||||
|
|
||||||
|
scanf("%d %d", &a, &b);
|
||||||
|
|
||||||
|
printf("C = %d\n", (a + b) * 2);
|
||||||
|
printf("S = %d\n", a * b);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
21
【实践课外】0.熟悉编程环境/7-4 简单最值.c
Normal file
21
【实践课外】0.熟悉编程环境/7-4 简单最值.c
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int max(int a, int b, int c) {
|
||||||
|
if (a > b && a > c) {
|
||||||
|
return a;
|
||||||
|
} else if (b > a && b > c) {
|
||||||
|
return b;
|
||||||
|
} else { // c > a && c > b
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int a, b, c;
|
||||||
|
|
||||||
|
scanf("%d%d%d", &a, &b, &c);
|
||||||
|
|
||||||
|
printf("%d\n", max(a, b, c));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user