实验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     printf(" o\n");
 9     printf("<H>\n");
10     printf("I I\n");
11     system("pause");
12     return 0;
13 }

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

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

 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 int main()
 4 {
 5     char ans1,ans2;
 6     printf("每次课前认真预习,课后及时复习了没(输入y或Y表示有,输入n或N表示没有):");
 7     ans1=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     system("pause");
16     return 0;
17 }

因为getchar()收取了回车键

 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 int main()
 4 {
 5     double x, y;
 6     char c1,c2,c3;
 7     int a1,a2,a3;
 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",x,y);
16 
17     system("pause");
18     return 0;
19 }

 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 int main()
 4 {
 5     int year;
 6         year=1000000000/(365*24*60*60);
 7         if((1000000000-year)<(0.5*365*24*60*60))
 8         printf("year=%d", year);
 9         else
10         year=year+1;
11         printf("year=%d",year);
12         system("pause");
13     return 0;
14 }

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

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

 1 #include<stdio.h>
 2 #include<math.h>
 3 #include<stdlib.h>
 4  int main()
 5 {
 6     double a,b,c,s,area;
 7     while(scanf("%lf%lf%lf",&a,&b,&c)!=EOF)
 8     {
 9 
10     s=(a+b+c)/2;
11     area=sqrt((s-a)*(s-b)*(s-c)*s);
12 
13     printf("area=%.3f\n",area);
14     }
15 
16     system("pause");
17     return 0;
18 }

 

posted @ 2024-03-16 23:32  中年男士  阅读(8)  评论(0编辑  收藏  举报