实验1:
源代码
1 #include<stdio.h> 2 int main() 3 { 4 printf(" O \n"); 5 printf("<H>\n"); 6 printf("I I\n"); 7 return 0; 8 }
1 #include<stdio.h> 2 int main() 3 { 4 printf(" O \n"); 5 printf("<H>\n"); 6 printf("I I\n"); 7 printf(" O \n"); 8 printf("<H>\n"); 9 printf("I I\n"); 10 11 return 0; 12 }
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 8 return 0; 9 }
实验2:
源代码
1 #include<stdio.h> 2 int main() 3 { 4 double a, b, c; 5 scanf("%lf%lf%lf", &a, &b, &c); 6 if(a+b>c && a-b<c) 7 printf("能构成三角形"); 8 else 9 printf("不能构成三角形"); 10 11 return 0; 12 }
实验3:
源代码
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 15 return 0; 16 17 }
实验4:
源代码
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 printf("a1 = %d, a2 = %d, a3 = %d\n", a1, a2, a3); 9 scanf("%c%c%c", &c1, &c2, &c3); 10 printf("c1 = %c, c2 = %c, c3 = %c\n", c1, c2, c3); 11 scanf("%lf,%lf", &x, &y); 12 printf("x = %lf, y = %lf\n",x, y); 13 return 0; 14 }
实验5:
源代码
1 #include <stdio.h> 2 int main() 3 { 4 int year; 5 // 补足代码 6 // ××× 7 double second; 8 second=1000000000; 9 year=second/31556952+0.5; 10 printf("10亿秒约等于%d年\n", year); 11 return 0; 12 }
实验6:
源代码
1 #include <stdio.h> 2 #include <math.h> 3 int main() 4 { 5 double x, ans; 6 while(scanf("%lf", &x) != EOF){ 7 ans = pow(x, 365); 8 printf("%.2f的365次方: %.2f\n", x, ans); 9 } 10 return 0; 11 }
实验7:
源代码
1 #include <stdio.h> 2 #include <math.h> 3 int main() 4 { 5 double C,F; 6 while(scanf("%lf", &C) != EOF){ 7 F= ( C * 9 / 5) + 32; 8 printf("摄氏度C = %lf 时\n", C); 9 printf("华氏度F = %lf\n", F); 10 } 11 return 0; 12 }
实验8:
源代码
1 #include <stdio.h> 2 #include <math.h> 3 int main() 4 { 5 double a, b, c, s , area; 6 while(scanf("%lf%lf%lf", &a, &b, &c) != EOF){ 7 s = (a + b + c )/2; 8 area = sqrt(s* (s-a)*(s-b)*(s-c)); 9 printf(" a=%.0lf b=%.0lf c=%.0lf area=%.3lf", a, b, c, area); 10 } 11 return 0; 12 }
标签:lf,main,return,int,实验,printf,include From: https://www.cnblogs.com/schince/p/18435753