实验素材2
实验21
1 #include<stdio.h> 2 3 int main() 4 5 { 6 7 char c1,c2,c3,c4,c5; 8 9 c1=getchar(); 10 11 c2=getchar(); 12 13 c3=getchar(); 14 15 c4=getchar(); 16 17 c5=getchar(); 18 19 putchar(c1); 20 21 putchar(c2); 22 23 putchar(c3); 24 25 putchar(c4); 26 27 putchar(c5); 28 29 return 0; 30 31 }
实验22
1 #include<stdio.h> 2 int main() 3 { 4 int year; 5 printf("input the year:"); 6 scanf("%d",&year); 7 if(year%4==0&&year%100!=0||year%400==0) 8 { 9 printf("year:%d,mouth:2,days:29",year); 10 } else { 11 printf("year:%d,mouth:2,days:28",year); 12 } 13 return 0; 14 }
实验23
1 #include<stdio.h> 2 int main() 3 { 4 int a,b,c; 5 scanf("%d%d%d",&a,&b,&c); 6 if(a+b<=c||a+c<=b||b+c<=a) 7 { 8 printf("不能构成三角形"); 9 } else if (a==b||a==c||b==c) { 10 if(a==b&&b==c){ printf("是等边三角形"); 11 } else { 12 printf("是等腰三角形"); 13 } 14 } else if (a*a+b*b==c*c||a*a+c*c==b*b||c*c+b*b==a*a) { 15 printf("是直角三角形"); 16 } else { 17 printf("是一般三角形"); 18 } 19 return 0; 20 21 } 22 23
、
实验24
1 #include<stdio.h> 2 int main() 3 { 4 double a,x,p,t; 5 scanf("%lf",&a); 6 int c; 7 c=a/500; 8 switch(c) 9 { 10 case 0:x=0.00;break; 11 case 1:x=0.05;break; 12 case 2:x=0.08;break; 13 case 3:x=0.08;break; 14 case 4:x=0.10;break; 15 case 5:x=0.10;break; 16 case 6:x=0.10;break; 17 case 7:x=0.10;break; 18 case 8:x=0.10;break; 19 case 9:x=0.10;break; 20 case 10:x=0.15;break; 21 } 22 t=a*x; 23 p=a-t; 24 printf("a=%lf,rate=%lf,tax=%lf,profit=%lf",a,x,t,p); 25 return 0; 26 } 27