实验二
#include <stdio.h> int main() { int year; int a=28; int b=29; scanf("%d",&year); if((year%100!=0&&year%4==0)||(year%400==0)) { printf("year:%d,month:2,day:%d",year,b);} else{printf("year:%d,month:2,day:%d",year,a);} return 0; }
#include <stdio.h> int main() { int a,b,c; scanf("%d%d%d",&a,&b,&c); if(a+b>c&&a+c>b&&b+c>a) { if(a==b&&b==c) printf("等边三角形"); else if(a==b||b==c||a==c){ if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a) printf("等腰直角三角形");else{printf("等腰三角形");} } else if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a){printf("直角三角形");} else {printf("一般三角形");} } else{printf("不是三角形");} return 0; }
#include <stdio.h> int main() { double a,b,c,d; int f; scanf("%lf",&a); if (a<500) {b=0.00,f=1;} else if(a<=500&&a<1000) {b=0.05,f=2;} else if(a>=1000&&a<2000) {b=0.08,f=3;} else if(a>=2000&&a<5000) {b=0.10,f=4;} else{b=0.15;f=5;} switch (f) { case 1:c=a*0.00; d=a-c; printf("a=%lf,rate=%lf,tax=%lf,profit=%lf\n",a,b,c,d);break; case 2:c=a*0.05; d=a-c; printf("a=%lf,rate=%lf,tax=%lf,profit=%lf\n",a,b,c,d);break; case 3:c=a*0.08; d=a-c; printf("a=%lf,rate=%lf,tax=%lf,profit=%lf\n",a,b,c,d);break; case 4:c=a*0.10; d=a-c; printf("a=%lf,rate=%lf,tax=%lf,profit=%lf\n",a,b,c,d);break; case 5:c=a*0.15; d=a-c; printf("a=%lf,rate=%lf,tax=%lf,profit=%lf\n",a,b,c,d);break; } return 0; }
#include <stdio.h> int main() { char a,b,c,d,e; a=getchar(); b=getchar(); c=getchar(); d=getchar(); e=getchar(); putchar(a); putchar(b); putchar(c); putchar(d); putchar(e); printf("\n"); return 0; }