#include<stdio.h> #include<math.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); return 0; }
#include<stdio.h> #include<math.h> int main(int argc, char* argv[]) { int year; scanf("%d",&year); if(year%400==0||(year%4==0&&year%100!=0)) printf("%d是闰年\n",year); else printf("%d不是闰年\n",year); return 0; }
#include"stdio.h" #include<math.h> int main() { int a,b,c; printf("请输入三角形的三边:"); scanf("%d%d%d",&a,&b,&c); if((a+b)>c&&(b+c)>a&&(c+a)>b) { if(a==b&&b==c&&a==c) printf("全等三角形"); else if(a==b||b==c||a==c) printf("等腰三角形"); else if((a*a+b*b-c*c==0||a*a+c*c-b*b==0||b*b+c*c-a*a==0)) printf("直角三角形"); else if(1) printf("一般三角形"); } else printf("不能构成三角形"); return 0; }
自写有错:
#include<stdio.h> #include<math.h> int main(){ int a,b,c; scanf("%d,%d,%d\n",&a,&b,&c); if(!a+b>c&&a+c>=b&&b+c>=a){ printf("不能构成三角形");} else{ if(a*a+b*b-c*c==0||a*a+c*c-b*b==0||b*b+c*c-a*a==0) {if(a==b||b==c||a==c) {printf("构成等腰直角三角形\n");} else{ printf("构成一般直角三角形\n");} } else{ if(a==b||b==c||a==c){ if(a==b&&a==c){ printf("构成等边三角形\n");} else{ printf("构成等腰三角形\n");} } else{ printf("构成一般三角形\n");} } } return 0;}
#include<stdio.h> #include<math.h> int main() { double a,rate,tax,profit; scanf("%lf",&a); if(a>=5000) rate = 0.15; else if(a >= 2000) rate = 0.10; else if(a >= 1000) rate = 0.08; else if(a >= 500) rate = 0.05; else if(a < 500) rate = 0; tax = a - (a*rate); profit = a - tax; printf("a = %lf \nrate=%lf \ntax=%lf \nprofit=%lf\n",a,rate,tax,profit); return 0; }
#include<stdio.h> #include<math.h> int main() { double a,rate,tax,profit; int b; scanf("%lf",&a); b = a/500; switch(b){ case 0: rate = 0.00; break; case 1: rate = 0.05; break; case 2: rate = 0.08; break; case 3: rate = 0.08; break; case 4: rate = 0.10; break; case 5: rate = 0.10; break; case 6: rate = 0.10; break; case 7: rate = 0.10; break; case 8: rate = 0.10; break; case 9: rate = 0.10; break; default: rate = 0.15; } tax = a - (a*rate); profit = a - tax; printf("a = %lf \nrate=%lf \ntax=%lf \nprofit=%lf\n",a,rate,tax,profit); return 0; }