#include<stdio.h> int main() { int i; float ave,sum; sum=0; int a[4]; printf("请输入四个整数:"); for(i=0;i<4;i++) { scanf("%d",&a[i]); sum=sum+a[i]; } ave=sum/4; printf("sum/4=%f\n",ave); printf("sum=%f\n",sum); return 0; }
#include<stdio.h> #include<math.h> int main() { float x,y; printf("请输入用户月用电量"); scanf("%f",&x); if(x>0&&x<=50){ printf("y=%.2f\n",y=0.53*x);} else if(x>50){ printf("y=%.2f\n",y=50*0.53+(x-50)*0.58);} else{ printf("Invalid value!"); } return 0;
后面的题有点蒙了,需要想想