#include int main(){ double x,sum=0,ave; int i; for(i=0;i<4;i++) { scanf("%lf",&x); sum=sum+x; } ave=(sum/4); printf("这4个数的和为%.1lf,平均值为%.1lf\n",sum,ave); return 0;}
#include #include int main(){ double x,cost; printf("输入一个x:"); scanf("%lf",&x); if(x>0&&x<=50) printf("cost=%.2f\n",cost=0.53*x); else if(x>50) printf("cost=%.2f\n",cost=50*0.53+(x-50)*0.58); else return 0;}
#include int main(){ double m,n,t,sum; printf("输入m,n:"); scanf("%lf%lf",&m,&n); sum=0; for(m;m<=n;m++) { t=m*m+1/m; sum=sum+t; } printf("结果是:%lf",sum); return 0; }
#include #include int main(){ int i,n; double sum,t; printf("请输入一个正整数n:"); scanf("%d",&n); sum=0; for(i=1;i<=n;i++) { t=pow(-1,i-1)*i/(2*i-1); sum=sum+t; } printf("sum=%lf",sum); return 0; }
#include #include int main(){ int i,n; double sum,t; sum=0; printf("请输入一个正整数n:"); scanf("%d",&n); for(i=1;i<=n;i++) { t=sqrt(i); sum=sum+t; } printf("sum=%.2lf",sum); return 0;}
#include double fact(int n);int main(){ int n,i; double e; e=0; printf("请输入一个正整数n:"); scanf("%d",&n); for(i=1;i<=n;i++) { e=e+fact(i); } printf("e=%.2lf",e); return 0;} double fact(int n){ int i; double product; product=1; for(i=1;i<=n;i++) { product=product*i; } return product;}