实验1

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

批注 2025-09-26 091831

(2)


 1 #include <stdio.h>
 2 #include<stdlib.h>
 3 int main()
 4 {
 5 printf(" O   O\n");
 6 printf("<H> <H>\n");
 7 printf("I I I I\n");
 8 
 9 
10 
11 
12 
13 system("pause");
14 return 0;
15 }
16   
View Code
批注 2025-09-26 092349

实验2

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

2

 

 



实验3

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

3

第二个问题被直接跳过

line9是为了防止问题二的输入被吞掉,防止计算机取回车符号

实验4

 1 #define _CRT_SECURE_NO_WARNINGS
 2 #include<stdio.h>
 3 int main()
 4 {
 5     double x, y;
 6     char c1, c2, c3;
 7     int a1, a2, a3;
 8     scanf("%d%d%d",& a1, &a2, &a3);/*没加&*/
 9     printf("a1 = %d, a2 = %d, a3 = %d\n", a1, a2, a3);
10     scanf("%c%c%c", &c1, &c2, &c3);
11     printf("c1 = %c, c2 = %c, c3 = %c\n", c1, c2, c3);
12     scanf("%lf%lf", &x, &y);
13     printf("x = %lf, y = %lf\n", x, y);/*应该是%lf*/
14     
15 
16     return 0;
17 }

4

实验5

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
    int year;
    year = 1000000000 / 31536000;
    printf("10亿秒约等于%d年\n", (int)(year+0.5));
    

    return 0;
}

5

 

实验6

 1 #define _CRT_SECURE_NO_WARNINGS
 2 #include<stdio.h>
 3 #include<math.h>
 4 int main()
 5 {
 6     long double x, ans;
 7     while (scanf("%Lf", &x) != EOF) {
 8         ans = powl(x, 365);
 9         printf("% .2Lf的365次方:% .2f\n", x,ans);
10     }
11 
12 
13     return 0;
14 }

6

实验7

 1 #define _CRT_SECURE_NO_WARNINGS
 2 #include<stdio.h>
 3 #include<math.h>
 4 int main()
 5 {
 6     double F, C;
 7     while (scanf("%lf", &C) != EOF) {
 8         F = (9.0 / 5.0) * C + 32;
 9         printf("摄氏度是%.2lf时,华氏度为%.2lf", C, F);
10     }
11 
12 
13     return 0;
14 }

屏幕截图 2025-09-26 201714

实验8

 1 #define _CRT_SECURE_NO_WARNINGS
 2 #include<stdio.h>
 3 #include<math.h>
 4 int main()
 5 {
 6     double a, b, c, s, p, n;
 7     while (scanf("%lf%lf%lf", &a, &b, &c) != EOF) {
 8         p = (a + b + c) / 2;
 9         n = p * (p - a) * (p - b) * (p - c);
10         s = sqrt(n);
11         printf("面积是:%.3lf", s);
12 
13     }
14 
15 
16     return 0;
17 }

8

 

posted @ 2025-09-26 20:34  deepsigh  阅读(17)  评论(1)    收藏  举报