2个回答
展开全部
#include <stdio.h>
void average(float a[], int size)
{
int i = 0;
float temp = 0.0;
for(i; i<size; i++)
temp += a[i];
printf("平均分为:%f", temp/size);
}
void max(float a[], int size)
{
int i = 1;
float temp = a[0];
for(i; i<size; i++)
if (temp < a[i])
temp = a[i];
printf("最高分是:%f", temp);
}
void min(float a[], int size)
{
int i = 1;
float temp = a[0];
for(i; i<size; i++)
if (temp>a[i])
temp = a[i];
printf("最低分是:%f", temp);
}
void main()
{
float a[10] = {100.0, 80.0, 30.0, 50.5, 70.5, 20.0, 80.5, 82.0, 99.0, 72.5};
average(a, 10);
max(a, 10);
min(a, 10);
}
void average(float a[], int size)
{
int i = 0;
float temp = 0.0;
for(i; i<size; i++)
temp += a[i];
printf("平均分为:%f", temp/size);
}
void max(float a[], int size)
{
int i = 1;
float temp = a[0];
for(i; i<size; i++)
if (temp < a[i])
temp = a[i];
printf("最高分是:%f", temp);
}
void min(float a[], int size)
{
int i = 1;
float temp = a[0];
for(i; i<size; i++)
if (temp>a[i])
temp = a[i];
printf("最低分是:%f", temp);
}
void main()
{
float a[10] = {100.0, 80.0, 30.0, 50.5, 70.5, 20.0, 80.5, 82.0, 99.0, 72.5};
average(a, 10);
max(a, 10);
min(a, 10);
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include "Stdio.h"
#include "Conio.h"
#include "String.h"
void min(float ch[])
{
int j;
float minnum;
minnum=ch[0];
for(j=0;j<10;j++)
{
if(minnum>ch[j])
minnum=ch[j];
}
printf("MIN is %f\n",minnum);
}
void max(float ch[])
{
int j;
float maxnum;
maxnum=ch[0];
for(j=0;j<10;j++)
{
if(maxnum<ch[j])
maxnum=ch[j];
}
printf("MAX is %f\n",maxnum);
}
void average(float ch[])
{
int j;
float averagenum,allnum;
for(j=0;j<10;j++)
{
allnum+=ch[j];
}
averagenum=allnum/10;
printf("AVERAGE is %f\n",averagenum);
}
//main get 10 students'score
int main(void)
{
int i,k;
float ch[10];
printf("Please input 10 number:\n");
for(i=0;i<10;i++)
{
k=i;
do
{
if(i!=k)
printf("Please input between 1 and 100\n");
printf("number %d =",i+1);
scanf("%f",&ch[i]);
k++;
}while(ch[i]<0 || ch[i]>100);
}
for(i=0;i<10;i++)
{
printf("number %d = %f\n",i+1,ch[i]);
}
min(ch);
max(ch);
average(ch);
getch();
return 0;
}
#include "Conio.h"
#include "String.h"
void min(float ch[])
{
int j;
float minnum;
minnum=ch[0];
for(j=0;j<10;j++)
{
if(minnum>ch[j])
minnum=ch[j];
}
printf("MIN is %f\n",minnum);
}
void max(float ch[])
{
int j;
float maxnum;
maxnum=ch[0];
for(j=0;j<10;j++)
{
if(maxnum<ch[j])
maxnum=ch[j];
}
printf("MAX is %f\n",maxnum);
}
void average(float ch[])
{
int j;
float averagenum,allnum;
for(j=0;j<10;j++)
{
allnum+=ch[j];
}
averagenum=allnum/10;
printf("AVERAGE is %f\n",averagenum);
}
//main get 10 students'score
int main(void)
{
int i,k;
float ch[10];
printf("Please input 10 number:\n");
for(i=0;i<10;i++)
{
k=i;
do
{
if(i!=k)
printf("Please input between 1 and 100\n");
printf("number %d =",i+1);
scanf("%f",&ch[i]);
k++;
}while(ch[i]<0 || ch[i]>100);
}
for(i=0;i<10;i++)
{
printf("number %d = %f\n",i+1,ch[i]);
}
min(ch);
max(ch);
average(ch);
getch();
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询