任务1:
task1.1
1 #include <stdio.h> 2 3 4 5 int main() 6 { 7 printf(" o \n"); 8 printf(" <H> \n"); 9 printf(" I I \n"); 10 printf(" o \n"); 11 printf(" <H> \n"); 12 printf(" I I \n"); 13 14 15 16 17 return 0; 18 19 20 }
task1.2
1 #include <stdio.h> 2 3 4 5 int main() 6 { 7 printf(" o o\n"); 8 printf("<H> <H>\n"); 9 printf("I I I I\n"); 10 11 12 13 14 return 0; 15 16 17 }
任务2:
task2
1 #include <stdio.h> 2 3 4 5 int main() 6 { 7 double a, b, c; 8 scanf_s("%lf%lf%lf", &a, &b, &c); 9 if (a + b >c && b + c >a && a + c > b) 10 printf("能构成三角形\n"); 11 else 12 printf("不能构成三角形\n"); 13 14 15 16 return 0; 17 18 19 }
任务3:
task3
1 #include <stdio.h> 2 3 4 5 int main() 6 { 7 char ans1, ans2; 8 printf("每次课前认真预习、课后及时复习了没? (输入y或Y表示有,输入n或N表示没有) :"); 9 10 ans1 = getchar(); 11 getchar(); 12 printf("\n动手敲代码实践了没? (输入y或Y表示敲了,输入n或N表示木有敲) : "); 13 ans2 = getchar(); 14 if ((ans1=='y'||ans1=='Y')&&(ans2=='y'||ans2=='Y')) 15 printf("\n罗马不是一天建成的, 继续保持哦:)\n"); 16 else 17 printf("\n罗马不是一天毁灭的, 我们来建设吧\n"); 18 19 return 0; 20 21 22 } 23
回答问题:结果是 第二个问题无法回答,ij语句直接判断给出了else对应的结果
原因是
任务4:
task4
1 #include<stdio.h> 2 3 4 int main() 5 { 6 7 double x, y; 8 char c1, c2, c3; 9 int a1, a2, a3; 10 11 scanf_s("%d%d%d", &a1, &a2, &a3); 12 printf("a1 = %d, a2 = %d, a3 = %d\n", a1, a2, a3); 13 14 scanf_s("%c%c%c", &c1, &c2, &c3); 15 printf("c1 = %c, c2 = %c, c3 = %c\n", c1, c2, c3); 16 17 scanf_s("%lf,%lf", &x, &y); 18 printf("x = %f, y = %lf\n", x, y); 19 return 0; 20 }
任务5:
task5
1 #include <stdio.h> 2 3 #include<math.h> 4 5 int main() 6 { 7 int year; 8 double hope; 9 hope= pow(10, 9); 10 year = hope / (365 * 24 * 3600); 11 printf("10亿秒约等于%d年\n", year); 12 13 14 15 return 0; 16 17 18 }
任务6:
task6.2
1 #include <stdio.h> 2 3 #include<math.h> 4 5 int main() 6 { 7 double x, ans; 8 9 while(scanf_s("%lf", &x) !=EOF) 10 { 11 ans = pow(x, 365); 12 printf("%.2f的365次方:%.2f\n",x,ans); 13 printf("\n"); 14 } 15 16 return 0; 17 18 19 } 20
任务7:
task7
1 #include <stdio.h> 2 #include<math.h> 3 4 int main() 5 { 6 double c,f; 7 8 while(scanf_s("%lf,%lf", &c,&f) !=EOF) 9 { 10 f = 9 * c / 5 + 32; 11 printf("摄氏度c等于%.2f时,华氏度f:%.2f\n",c,f); 12 printf("\n"); 13 } 14 15 return 0; 16 17 18 }
任务8:
task8
1 #include <stdio.h> 2 #include<math.h> 3 4 int main() 5 { 6 int a, b, c,s; 7 double area; 8 9 10 while(scanf_s("%d%d%d", &a,&b,&c) !=EOF) 11 { 12 s = a + b +c; 13 area = sqrt(s * (s - a) * (s - b) * (s - c)); 14 printf("a=%d,b=%d,c=%d,area=%.3f\n",a,b,c,area); 15 printf("\n"); 16 } 17 18 return 0; 19 20 21 } 22
标签:11,10,return,int,输入输出,程序,printf,编写,include From: https://www.cnblogs.com/sunhope/p/18432186