求指教 |
|
YJSJ
L0
• 2019-12-03 • 回复 4 • 只看楼主
• 举报
|
学习敲代码中,有没有大佬给说一下这个哪里错了啊,找了好久不知道。。。
#include <stdio.h>
#define N 30
int Average(int score[],int n);
int Max(int score[],int n);
int Min(int score[],int n);
void ReadScord(int score[],int n);
int main()
{
int score[N],aver,max,min,n,num,i; printf("Input:");
scanf("%d",&n);
ReadScord(score,n);
aver = Average(score,n);
max = Max(score,n);
min = Min(score,n);
for(i=1;i<n;i++)
{
num = 0;
if(score[i]<aver)
num++;
}
printf("aver = %d,max = %d,min = %d,num = %d",aver,max,min,num);
return 0;
}
int Average(int score[],int n)
{
int i,sum = 0;
for(i=1;i<n;i++)
{
sum = sum + score[i];
}
return sum/n;
}
int Max(int score[],int n)
{ int i,max;
max = score[0];
for(i=1;i<=n;i++)
{
max = score[0];
if(score[i]>max)
max = score[i];
else
max = max;
} return max;
}
int Min(int score[],int n)
{ int i,min;
min = score[0];
for(i=1;i<=n;i++)
{
if(score[i]<min)
min = score[i];
else
min = min;
}
return min;
}
void ReadScord(int score[],int n)
{
int i;
printf("输入分数:");
for(i=1;i<=n;i++);
{
scanf("%d",&score[i]);
}
}
#include <stdio.h>
#define N 30
int Average(int score[],int n);
int Max(int score[],int n);
int Min(int score[],int n);
void ReadScord(int score[],int n);
int main()
{
int score[N],aver,max,min,n,num,i; printf("Input:");
scanf("%d",&n);
ReadScord(score,n);
aver = Average(score,n);
max = Max(score,n);
min = Min(score,n);
for(i=1;i<n;i++)
{
num = 0;
if(score[i]<aver)
num++;
}
printf("aver = %d,max = %d,min = %d,num = %d",aver,max,min,num);
return 0;
}
int Average(int score[],int n)
{
int i,sum = 0;
for(i=1;i<n;i++)
{
sum = sum + score[i];
}
return sum/n;
}
int Max(int score[],int n)
{ int i,max;
max = score[0];
for(i=1;i<=n;i++)
{
max = score[0];
if(score[i]>max)
max = score[i];
else
max = max;
} return max;
}
int Min(int score[],int n)
{ int i,min;
min = score[0];
for(i=1;i<=n;i++)
{
if(score[i]<min)
min = score[i];
else
min = min;
}
return min;
}
void ReadScord(int score[],int n)
{
int i;
printf("输入分数:");
for(i=1;i<=n;i++);
{
scanf("%d",&score[i]);
}
}