daizybroa

导航

作业1

任务1

#include<stdio.h>
#include<stdlib.h>
#define _CRT_SECURE_NO_WARNINGS

int main()
{
	printf(" O \n");
	printf("<H>\n");
	printf("I I\n");

	system("pause");

	return 0;
}

  

 

 

任务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 
 9     printf(" O \n");
10     printf("<H>\n");
11     printf("I I\n");
12 
13     system("pause");
14 
15     return 0;
16 }

 

任务1.2

 1 #include<stdio.h>
 2 #include<stdio.h>
 3 int main()
 4 {
 5     printf(" O     O\n");
 6     printf("<H>   <H>\n");
 7     printf("I I   I I\n");
 8 
 9     system("pause");
10 
11     return 0;
12 }

任务2

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

 

任务3


#include<stdlib.h>
#include<stdio.h>


int main()
{
char ans1, ans2;
int y, Y;


printf("每次课前认真预习、课后及时复习了没? (输入y或Y表示有,输入n或N表示没有)");
ans1 = getchar();


getchar();


printf("\n动手敲代码实践了没? (输入y或Y表示敲了,输入n或N表示木有敲) : ");
ans2 = getchar();


if ((ans1 == 'y' || ans1 == 'Y') && (ans2 == 'y' || ans2 == 'Y'))
printf("\n罗马不是一天建成的, 继续保持哦:)\n");


else
printf("\n罗马不是一天毁灭的, 我们来建设吧\n");

return 0;



}

 

任务4

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

任务5

 1 #include<stdio.h>
 2 #include <stdio.h>
 3 int main()
 4 {
 5     int year;
 6     double t;
 7     
 8     t = 1000000000 / 60 / 60 / 24 / 365;
 9     
10     year = t + 0.5;
11     
12     printf("10亿秒约等于%d年\n", year);
13     
14     return 0;
15 }

任务6

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

 任务7

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

 任务8

 1 #define _CRT_SECURE_NO_WARNINGS 1
 2 #include<stdio.h>
 3 #include<stdlib.h>
 4 #include<math.h>
 5 int main()
 6 {
 7     double a, b, c, s, p;
 8     while (scanf("%lf%lf%lf", &a, &b, &c) != EOF)  
 9     {
10         
11         if (a + b > c && a + c > b && b + c > a)
12         {
13             p = 1.0 / 2.0 * (a + b + c);
14             s = sqrt(p * (p - a) * (p - b) * (p - c));  
15             printf("三角形面积为%.3lf\n", s);
16         }
17         else
18         {
19             printf("不能构成三角形");
20         }
21     }
22     return 0;
23 }

 

posted on 2025-03-10 13:11  孤独在一方的星  阅读(12)  评论(0)    收藏  举报