摘要:
#includeint main(){ int i,n,sum; int fact(int n); sum=0; n=100; for(i=1;i<=n;i++){ sum=sum+fact(i); } printf("1!+2!+...+100!=%d\n",sum); return 0;}int fact(int n){ int i; double result; result=1; for(i=1;i<=n;i++){ result=result*i; } return res... 阅读全文
摘要:
#include#includeint main(){ int i,n,sum; printf("Enter n:"); scanf("%d",&n); sum=0; for(i=1;i<=n;i++){ sum=sum+pow(2,i); } printf("result=%d\n",sum); return 0;} 阅读全文
摘要:
#include#includeint main(){ int m,y; double rate,money,loan; double s(double rate,double loan,int m); printf("输入贷款本金和月利率:"); scanf("%lf%lf",&loan,&rate); for(y=5;y<=30;y++){ m=12*y; money=s(rate,loan,m); printf("年分%d 月还款额%.1f\n",y,money); } retur... 阅读全文
摘要:
#includeint main(){ int i,n,flag,a; double sum,item; printf("Enter n:"); scanf("%d",&n); flag=1; a=1; sum=0; for(i=1;i<=n;i++){ item=flag*1.0/a; sum=sum+item; flag=-flag; a=a+2; } printf("result=%.4f\n",sum); return 0;} 阅读全文
摘要:
#includeint main(){ int m,n,a; double result,i; printf("输入两个正整数m和n:"); scanf("%d%d",&m,&n); if(n<m){ a=n; n=m; m=a; } result=0; for(i=m;i<=n;i++){ result=result+i*i+1/i; } printf("result=%.2f",result); return 0;} 阅读全文
摘要:
#includeint main(){ int i,n; double x,sum; printf("输入实数x和正整数n:"); scanf("%lf%d",&x,&n); sum=1; for(i=1;i<=n;i++){ sum=sum*x; } printf("x^n=%.2f\n",sum); return 0;} 阅读全文
摘要:
#includeint main(){ int num1,num2,a; double m,n; printf("enter num1 and num2:"); scanf("%d%d",&num1,&num2); if(num1<num2){ a=num1; num1=num2; num2=a; } printf("result1=%d\n",num1+num2); printf("result2=%d\n",num1-num2); printf("result3=%d\n&quo 阅读全文
摘要:
#includeint main(){ int n,i; double x,y; printf("Enter n:"); scanf("%d",&n); for(i=1;i<=n;i++){ printf("Enter x:"); scanf("%lf",&x); if(x<=0) printf("输入错误,请重新输入\n"); else if(x<=50){ y=0.53*x; } else{ y=26.5+0... 阅读全文
摘要:
#includeint main(){ int i,n; double r,v,h; double cylinder(double r,double h); printf("enter n:"); scanf("%d",&n); for(i=1;i<=n;i++){ printf("Enter r and h:"); scanf("%lf%lf",&r,&h); if((r<=0)||(h<=0)) { printf("输入错误,重新输入\n"); } 阅读全文
摘要:
#includeint main(){ double r,s; printf("enter r:"); scanf("%lf",&r); if(r>0){ s=3.14159*r*r; printf("s=%.3f\n",s); } else printf("输入错误"); return 0;} 阅读全文