3个回答
展开全部
for(j=0;j<9;j++)//由小到大排列
{
for(i=0;i<(9-j);i++)
{
if(data[i]>data[i+1])
{
temp=data[i];
data[i]=data[i+1];
data[i+1]=temp;
}
}
}
★最大值为data[9]
★最小值为data[0]
★平均值为avr:
sum=0;
for(i=0;i<10;i++)
{
sum += data[i];
}
avr = sum/10;
★超过平均值的人数为num:
num=0;
for(i=0;i<10;i++)
{
if( data[i] > avr)
{
num++;
}
}
具体实现你整理吧。
{
for(i=0;i<(9-j);i++)
{
if(data[i]>data[i+1])
{
temp=data[i];
data[i]=data[i+1];
data[i+1]=temp;
}
}
}
★最大值为data[9]
★最小值为data[0]
★平均值为avr:
sum=0;
for(i=0;i<10;i++)
{
sum += data[i];
}
avr = sum/10;
★超过平均值的人数为num:
num=0;
for(i=0;i<10;i++)
{
if( data[i] > avr)
{
num++;
}
}
具体实现你整理吧。
展开全部
#define N 10
#include <stdio.h>
void main(){
float point[N];
int i;
float min,max;
float sum = 0;
int up_average = 0;
printf("input 10 number:\n");
scanf("%f", &point[0]);
max = point[0];
min = point[0];
sum = point[0];
for(i = 1; i < N; i++){
scanf("%f", &point[i]);
sum += point[i];
if(point[i] < min){
min = point[i];
}
if(point[i] > max){
max = point[i];
}
}
printf("max is %f\nmin is %f\naverage is %f\n",max,min,sum / N);
for(i = 0; i < N; i++){
if(point[i] >= (sum / N)){
up_average++;
}
}
printf("up_average is %d\n",up_average);
}
#include <stdio.h>
void main(){
float point[N];
int i;
float min,max;
float sum = 0;
int up_average = 0;
printf("input 10 number:\n");
scanf("%f", &point[0]);
max = point[0];
min = point[0];
sum = point[0];
for(i = 1; i < N; i++){
scanf("%f", &point[i]);
sum += point[i];
if(point[i] < min){
min = point[i];
}
if(point[i] > max){
max = point[i];
}
}
printf("max is %f\nmin is %f\naverage is %f\n",max,min,sum / N);
for(i = 0; i < N; i++){
if(point[i] >= (sum / N)){
up_average++;
}
}
printf("up_average is %d\n",up_average);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询