任务一
源代码
点击查看代码
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
printf(" O O\n");
printf(" <H> <H>\n");
printf(" I I I I\n");
return 0;
}
##运行结果
![image]()
任务二
源代码
点击查看代码
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
double a, b, c;
scanf("%lf %lf %lf", &a, &b, &c);
if (a + b > c && a + c > b && b + c > a) {
printf("能构成三角形\n");
}
else {
printf("不能构成三角形\n");
}
return 0;
}
##运行结果
![image]()
任务三
源代码
点击查看代码
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
char ans1, ans2;
printf("每次课及时预习/复习了没?(是- 输入y或Y,否- 输入n或N):");
scanf("%c", &ans1);
getchar();
printf("动手敲代码实践了没?(是- 输入y或Y,否- 输入n或N):");
scanf("%c", &ans2);
if ((ans1 == 'y' || ans1 == 'Y') && (ans2 == 'y' || ans2 == 'Y')) {
printf("罗马不是一天建成的,继续保持哦:)\n");
}
else {
printf("罗马不是一天毁灭的,我们来建设吧\n");
}
return 0;
}
##运行结果
![image]()
任务四
源代码
点击查看代码
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
int main() {
int year;
year = round(1000000000.0 / (365.0 * 24.0 * 3600.0));
printf("10亿秒约等于%d年\n", year);
return 0;
}
##运行结果
![image]()
任务五
源代码
点击查看代码
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
double c, f;
scanf("%lf", &c);
f = c * 9.0 / 5.0 + 32.0;
printf("摄氏度c = %.2f 时,华氏温度f = %.2f\n", c, f);
return 0;
}
##运行结果
![image]()
任务六
源代码
点击查看代码
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
int main() {
double a, b, c, s, area;
scanf("%lf %lf %lf", &a, &b, &c);
s = (a + b + c) / 2.0;
area = sqrt(s * (s - a) * (s - b) * (s - c));
printf("a = %g, b = %g, c = %g, area = %.3f\n", a, b, c, area);
return 0;
}
##运行结果
![image]()