task1_1
1 #include <stdio.h> 2 int main() 3 { 4 printf(" O\n"); 5 printf("<H>\n"); 6 printf("I I\n"); 7 8 printf(" O\n"); 9 printf("<H>\n"); 10 printf("I I\n"); 11 return 0; 12 }
task1_2
1 #include <stdio.h> 2 int main() 3 { 4 printf(" O O\n"); 5 printf("<H> <H>\n"); 6 printf("I I I I\n"); 7 return 0; 8 }
task2
1 #include <stdio.h> 2 int main() 3 { 4 5 float a, b, c; 6 7 while(scanf("%f%f%f", &a, &b, &c) != EOF) 8 if (a+b>c && a+c>b && b+c>a) 9 printf("能构成三角形\n"); 10 else 11 printf("不能构成三角形\n"); 12 return 0; 13 }
task3
1 #include <stdio.h> 2 int main() 3 { 4 char ans1, ans2; 5 printf("每次课前认真预习、课后及时复习了没? (输入y或Y表示有,输入n或N表示没有) :"); 6 ans1 = getchar(); 7 getchar(); 8 printf("\n动手敲代码实践了没? (输入y或Y表示敲了,输入n或N表示木有敲) : "); 9 ans2 = getchar(); 10 if((ans1=='y'||ans1=='Y')&&(ans2=='y'||ans2=='Y')) 11 printf("\n罗马不是一天建成的, 继续保持哦:)\n"); 12 else 13 printf("\n罗马不是一天毁灭的, 我们来建设吧\n"); 14 return 0; 15 }
去掉line7程序会在第一次输入后直接结束
task4
1 #include<stdio.h> 2 int main() 3 { 4 double x, y; 5 char c1, c2, c3; 6 int a1, a2, a3; 7 //scanf("%d%d%d",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("%f,%lf",&x,&y); 13 scanf("%lf,%lf", &x, &y); 14 printf("x = %lf, y = %lf\n", x, y); 15 return 0; 16 }
task5
1 #include <stdio.h> 2 int main() 3 { 4 int year; 5 double a = 1e9; 6 year = a /(365 * 24 * 60 * 60)+0.5; 7 printf("10亿秒约等于%d年\n", year); 8 return 0; 9 }
task6
1 #include <stdio.h> 2 #include <math.h> 3 int main() 4 { 5 double x, ans; 6 7 while (scanf("%lf", &x) != EOF) 8 { 9 ans = pow(x, 365); 10 printf("%.2f的365次方: %.2f\n", x, ans); 11 } 12 return 0; 13 }
task7
1 #include <stdio.h> 2 int main() 3 { 4 double C, F; 5 while (scanf("%lf", &C) != EOF) 6 { 7 F = 9.0 / 5 * C + 32; 8 printf("摄氏度c = %.2lf时,华氏度f = %.2lf\n", C, F); 9 } 10 return 0; 11 }
task8
1 #include <stdio.h> 2 #include <math.h> 3 int main() 4 { 5 int a,b,c; 6 double s, area; 7 while (scanf("%d%d%d", &a, &b, &c) != EOF) 8 { 9 s = (a + b + c) / 2.0; 10 area = sqrt(s * (s - a) * (s - b) * (s - c)); 11 printf("a = %d,b = %d,c = %d,area = %.3lf\n", a, b, c, area); 12 } 13 return 0; 14 }
标签:main,return,int,scanf,输入输出,C语言,printf,编写,include From: https://www.cnblogs.com/1262438226qqcom/p/18071356