C语言的题,高手快点来救救我,
发布网友
发布时间:2024-09-26 16:26
我来回答
共1个回答
热心网友
时间:2024-10-08 23:27
#incude<stdio.h>
#define N 5
void main() { int a[N]={ 8,6,5,4,1 },i,j,k;
for ( i=0;i<N-1;i++ ) for ( j=i+1;j<N;j++ ) if ( a[i]>a[j] ) {k=a[i];a[i]=a[j];a[j]=k;}
for ( i=0;i<N;i++ ) printf("%d ",a[i]); printf("\n");
}
#include<stdio.h>
#deinfe N 3
#define M 5
void main() { float s[N][M],av[N],tav; int i,j;
for ( i=0;i<N;i++ ) { av[i]=0; for ( j=0;j<M;j++ ) scanf("%f",&s[i][j]); }
for ( i=0;i<N;i++ ) { for ( j=0;j<M;j++ ) av[i]+=s[i][j]; av[i]/=M; }
for ( i=0,tav=0;i<M;i++ ) tav+=av[i]; tav/=N;
printf("每名学生平均分:"); for ( i=0;i<N;i++ ) printf("%.1f ",av[i]);
printf("\n总平均分:%.1f\n",tav;
}
热心网友
时间:2024-10-08 23:27
#incude<stdio.h>
#define N 5
void main() { int a[N]={ 8,6,5,4,1 },i,j,k;
for ( i=0;i<N-1;i++ ) for ( j=i+1;j<N;j++ ) if ( a[i]>a[j] ) {k=a[i];a[i]=a[j];a[j]=k;}
for ( i=0;i<N;i++ ) printf("%d ",a[i]); printf("\n");
}
#include<stdio.h>
#deinfe N 3
#define M 5
void main() { float s[N][M],av[N],tav; int i,j;
for ( i=0;i<N;i++ ) { av[i]=0; for ( j=0;j<M;j++ ) scanf("%f",&s[i][j]); }
for ( i=0;i<N;i++ ) { for ( j=0;j<M;j++ ) av[i]+=s[i][j]; av[i]/=M; }
for ( i=0,tav=0;i<M;i++ ) tav+=av[i]; tav/=N;
printf("每名学生平均分:"); for ( i=0;i<N;i++ ) printf("%.1f ",av[i]);
printf("\n总平均分:%.1f\n",tav;
}