实验1

实验任务1

源文件

 1 #include<stdio.h>
 2 #include<math.h>
 3 #include<stdlib.h>
 4 int main()
 5 { 
 6     printf(" O \n");
 7     printf("<H>\n");
 8     printf("I I \n");
 9     printf(" O \n");
10     printf("<H>\n");
11     printf("I I \n");
12 return 0;
View Code
 1 #include<stdio.h>
 2 #include<math.h>
 3 #include<stdlib.h>
 4 int main()
 5 { 
 6     printf(" O \t");
 7     printf(" O\n");
 8     printf("<H> \t");
 9     printf("<H>\n");
10     printf("I I\t");
11     printf("I I \n");
12 return 0;
13 
14 }
View Code

图片屏幕截图 2025-09-26 143544

屏幕截图 2025-09-26 143412

实验任务2

源文件

 1 #include<stdio.h>
 2 #include<math.h>
 3 #include<stdlib.h>
 4 int main(){
 5     double a, b, c;
 6     scanf_s("%lf%lf%lf", &a, &b, &c);
 7     if (a + b > c && a + c > b && b + c > a)
 8         printf("能构成三角形\n");
 9     else
10         printf("不能构成三角形\n");
11 
12 return 0;
View Code

图片屏幕截图 2025-09-26 144309

实验任务3

源文件

 1 #include<stdio.h>
 2 int main()
 3 {
 4     char ans1, ans2;
 5     printf("每次课前认真预习,课后及时复习了没?");
 6     ans1 = getchar();
 7     getchar();
 8     printf("动手认真实践了没");
 9     ans2 = getchar();
10     if (ans1 != 'n' && ans1 != 'N' && ans2 != 'n' && ans2 != 'N')
11     
12         printf("罗马不是一天建成的,继续保持\n");
13     
14     else
15         printf("罗马不是一天毁灭的,我们来建设吧\n");
16 
17     
18     
19         return 0;
20     
21 }
View Code

图片屏幕截图 2025-09-26 173306

 结果:不会输入ans2;原因:ans2的getchar读取了回车

实验任务4

源文件

 1 #include<stdio.h>
 2 #include<math.h>
 3 #include<stdlib.h>
 4 int main(){
 5     double x, y;
 6     char c1, c2, c3;
 7     int a1, a2, a3;
 8     scanf_s("%d%d%d", &a1, &a2, &a3);
 9     printf("a1=%d,a2=%d,a3=%d\n", a1, a2, a3);
10 
11     c1 = getchar(); c2 = getchar();
12     c3 = getchar();
13 
14     printf("c1=%c,c2=%c,c3=%c\n", c1, c2, c3);
15     scanf_s("%lf%lf", &x, &y);
16     printf("x=%f,y=%lf\n", x, y);
17 
18 
19 
20 return 0;
View Code

图片屏幕截图 2025-09-26 153311

实验任务5

源文件

 1 #include<stdio.h>
 2 #include<math.h>
 3 #include<stdlib.h>
 4 int main(){
 5     int year;
 6     double a = pow(9, 10);
 7     year = a / 3600 / 24 / 365 + 0.5;
 8     printf("9的10次方秒约为%d年", year);
 9 
10 
11 
12 return 0;
13 
14 }
View Code

图片屏幕截图 2025-09-26 153913

实验任务6

源文件

 1 #include<stdio.h>
 2 #include<math.h>
 3 #include<stdlib.h>
 4 int main()
 5 {
 6     double x, ans;
 7     while (scanf_s("%lf", &x) != EOF)
 8     {
 9         ans = pow(x, 365);
10         printf("%.2f的365次方:%.2f\n", x, ans);
11         printf("\n");
12     }
13 
14 return 0;
15 }
View Code

图片屏幕截图 2025-09-26 155030

实验任务7

源文件

 1 #include<stdio.h>
 2 int main()
 3 {
 4     double F, C;
 5     while (scanf_s("%lf", &C) != EOF)
 6     {
 7         F = 1.8 * C + 32;
 8         printf("摄氏度为%0.2f时,华氏度为%0.2f", C, F);
 9         printf("\n");
10     }
11         return 0;
View Code

图片屏幕截图 2025-09-26 162602

实验任务8

源文件

 1 #include<stdio.h>
 2 #include<math.h>
 3 #include<stdlib.h>
 4 int main()
 5 {
 6     double a, b, c, area,s;
 7     while (scanf_s("%lf%lf%lf", &a, &b, &c) != EOF)
 8     {
 9         s = (a + b + c) / 2;
10         area = sqrt(s * (s - a) * (s - b) * (s - c));
11         printf("a=%.0f,b=%.0f,c=%.0f,area=%0.3f", a,b,c,area); 
12         printf("\n");
13     }
14 
15 return 0;
16 }
View Code

图片屏幕截图 2025-09-26 160527

 

posted @ 2025-09-29 08:31  空元  阅读(12)  评论(1)    收藏  举报