C语言题目求解?
1个回答
展开全部
#include<stdio.h>
#define N 10
void input(int score[N]) { int m,n,i; float av;
for ( i=0;i<N;i++ ) scanf("%d",&score[i]);
m=n=av=score[0];
for ( i=1;i<N;i++ ) {
if ( m<score[i] ) m=score[i]; else if ( n>score[i] ) n=score[i];
av+=score[i];
}
av/=N; printf("%d %d %f\n",m,n,av);
}
void sort(int score[N]) { int i,j,k;
for ( i=0;i<N-1;i++ )
for ( j=i+1;j<N;j++ ) if ( score[i]<score[j] ) {k=score[i];score[i]=score[j];score[j]=k;}
}
void print(int score[N]) { int i;
for ( i=0;i<N;i++ ) printf("%d ",score[i]); printf("\n");
}
void main() { int a[N]; input(a); sort(a); print(a); }
#define N 10
void input(int score[N]) { int m,n,i; float av;
for ( i=0;i<N;i++ ) scanf("%d",&score[i]);
m=n=av=score[0];
for ( i=1;i<N;i++ ) {
if ( m<score[i] ) m=score[i]; else if ( n>score[i] ) n=score[i];
av+=score[i];
}
av/=N; printf("%d %d %f\n",m,n,av);
}
void sort(int score[N]) { int i,j,k;
for ( i=0;i<N-1;i++ )
for ( j=i+1;j<N;j++ ) if ( score[i]<score[j] ) {k=score[i];score[i]=score[j];score[j]=k;}
}
void print(int score[N]) { int i;
for ( i=0;i<N;i++ ) printf("%d ",score[i]); printf("\n");
}
void main() { int a[N]; input(a); sort(a); print(a); }
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询