实验任务1
1 #include <stdio.h> 2 int main () 3 { 4 printf(" o \n"); 5 printf("<H>\n"); 6 printf("I I \n"); 7 8 return 0; 9 10 }
运行结果
task1_1
task1_2
实验任务2
1 #include <stdio.h> 2 int main () 3 { 4 float a , b , c; 5 scanf ("%f%f%f" , &a ,&b ,&c); 6 7 if (a + b >c && a- b > c) 8 printf ("能构成三角形\n"); 9 else 10 11 printf("不能构成三角形\n"); 12 13 14 return 0; 15 16 }
运行结果
实验任务3
1 #include <stdio.h> 2 int main () 3 { 4 char ans1 , ans2; 5 6 printf("每次课前认真预习、课后及时复习了没?(输入y或Y表示有, 输入n或N表示没有);"); 7 ans1 = getchar(); 8 9 getchar(); 10 11 printf("\n动手敲代码实践了没?(输入y或Y表示有, 输入n或N表示没有);"); 12 ans2 = getchar(); 13 14 getchar(); 15 16 if(ans1 == 'y'||ans1 == 'Y'&&(ans2 == 'y' || ans2 == 'Y')) 17 printf ("\n罗马不是一天建成的,继续保持哦:)\n"); 18 19 else 20 printf("\n罗马不是一天毁灭的,我们来建设吧\n"); 21 22 23 return 0; 24 25 }
运行结果
实验任务4
1 #include <stdio.h> 2 int main () 3 { 4 double x, y; 5 char c1 , c2 , c3; 6 int a1 , a2 , a3; 7 8 scanf("%d%d%d", &a1 , &a2 ,&a3); 9 printf("a1 =%d ,a2 = %d , a3 = %d\n", a1 ,a2 , a3); 10 11 scanf("%c%c%c", &c1 , &c2 , &c3); 12 printf("c1 = %c , c2 = %c , c3 = %c\n",c1 , c2 ,c3 ); 13 14 scanf ("%lf%lf",&x , &y ); 15 printf ("x = %lf , y = %lf\n" ,x,y); 16 17 18 return 0; 19 20 }
运行结果
实验任务5
1 #include<stdio.h> 2 int main(){ 3 int year; 4 int j = 1; 5 double i = 1; 6 int t,m; 7 8 while(j<=9){ 9 i*=10; 10 j++; 11 12 } 13 year = i/(60*60*24*365); 14 15 t = i/(60*60*24*365)*100; 16 m = t%100; 17 if(m>=50) 18 year+=1; 19 else if(m<50) 20 year = year+0; 21 22 23 printf("10亿秒约等于%d年\n",year); 24 25 26 27 28 29 30 31 return 0; 32 }
运行结果
实验任务6
1 #include<stdio.h> 2 #include<math.h> 3 int main() 4 { 5 double x , ans; 6 7 scanf("%lf", &x); 8 ans = pow(x,365); 9 printf("%.2lf的365次方: %.2f\n", x , ans); 10 11 12 13 14 15 16 17 18 19 20 return 0; 21 }
tsak 6_2
#include<stdio.h>
#include<math.h>
int main()
{
double x , ans;
while(scanf("%lf",&x)!=EOF)
{
ans = pow(x,365);
printf("%.2f的365次方为:%.2f\n",x,ans);
printf("\n");}
return 0;
}
实验任务7
1 #include<stdio.h> 2 int main(){ 3 double c,f; 4 5 while(scanf("%lf",&c)!=EOF) 6 { 7 f = 9*c/5 + 32; 8 printf("摄氏度c = %.2f时,华氏度f = %.2f\n",c,f); 9 printf("\n"); 10 } 11 12 return 0; 13 }
实验8
1 #include<stdio.h> 2 #include<math.h> 3 int main(){ 4 int a,b,c; 5 double s,area; 6 while(scanf("%d%d%d",&a,&b,&c)!=EOF) 7 { 8 s = (a+b+c)/2; 9 area = sqrt(s*(s-a)*(s-b)*(s-c)); 10 printf("a = %d,b = %d,c = %d,area = %.3f\n",a,b,c,area); 11 printf("\n"); 12 } 13 14 return 0; 15 }
标签:include,return,int,scanf,实验,printf,main From: https://www.cnblogs.com/fz1003yy/p/17744392.html