1.3 5.1 55.1 66.1 88.1
排序前:
1.30 5.10 55.10 66.10 88.10
排序后:
88.10 66.10 55.10 5.10 1.30
数组平均值为:43.139999。
Press any key to continue
#include "stdio.h"
#define N 5 //自己改成15 我是为了测试方便 改的 5
main()
{
int i,j;
float tmp,sum,a[N];
for (i=0,sum=0;i
scanf("%f",&a[i]);
sum +=a[i];
}
printf("排序前:\n");
for (i=0;i
printf("\n");
for (i=0;i
for (j=0;j
if ( a[j] {
tmp = a[j];
a[j] = a[j+1];
a[j+1] = tmp;
}
}
}
printf("排序后:\n");
for (i=0;i
printf("\n");
printf("数组平均值为:%f。\n",sum/N);
}
int main()
{
float f[15]={0.0};
float average=0.0;
for(int i=0;i<15;i++)
scanf("%f",f+i);
for(int i=0;i<15;i++)
averge+=f[i];
average/=15;
return 1;
}