博文
薪水发放程序(可以使所发的纸币数量最少)(2006-02-05 16:53:00)
摘要:#include<stdio.h>main(){ float x; int y,i50,i20,i10,i5,i1,i050,i010; do{ printf("Input the salery:\n"); scanf("%f",&x); if(x<=0) printf("Data ERROR!"); }while(x<=0); y=(int)((x+0.0005)*100);//消除计算机在处理浮点数时产生的误差,如:程序main() // { float a=2.50; //  ......
字母金字塔程序(2006-02-03 20:36:00)
摘要:#include<stdio.h>#include<ctype.h>void main(void){ char c,c1,c2,top; printf("Input a character:\n"); top=isupper(c=getchar())?'A':(islower(c)?'a':'\0'); if(top) { for(c1=top;c1<=c;++c1) { printf("%*c",40-(c1-top<<1)); for(c2=top;c2<=c1;++c2) printf("%2c",c2); for(c2=c1-1;c2>=top;--c2) printf("%2c",c2); printf("\n"); } }}......
通过三角形三边求面积(2006-02-03 20:01:00)
摘要:#include<math.h>#include<stdio.h>main(){ float a,b,c,s=0; double area=0; int flag=1, q; do { while(flag) { printf("input the datas:\n"); scanf("%f%f%f",&a,&b,&c); if(a+b<=c||a+c<=b||b+c<=a) { flag=1; printf("the datas you input can't conbine a triangle;please input other datas.\n"); } else flag=0;
} s=(a+b+c)/2; printf("%f\n",s); area=sqrt(s*(s-a)*(s-b)*(s-c)); printf("%5.3f",area); printf("continue or not?\n1---yes;\n0---no;\n"); scanf("%d",&q); if(q==1) flag=1; }while(flag);}......
