#include
#define N 50 //學生人數
#define M 3 //課程門數
void Input(int score[][M+3], int n);
{
int i, j, sum;
printf("Input Number and %d score:\n",M);
for (i = 0; i < n; i++)
{
sum = 0;
printf("%d:",i+1);
for (j = 0; j <= M; j++)
{
scanf_s("%d",&score[i][j]);
if (j != 0)
sum += score[i][j];
}
score[i][M+1] = sum;
score[i][M + 2] = sum / M;
}
}
void Output(int score[][M + 3],int n)
{
int i, j;
printf("\nNumber \t");
for (i = 0; i < M; i++)
printf("sub%d\t", i + 1);
printf("Total\tAverage\n");
printf("-----------------------------------------\n");
for (i = 0; i < n; i++)
{
for (j = 0; j < M + 3; j++)
printf("%d\t", score[i][j]);
printf("\n");
}
}
void Sort(int a[][M + 3],int n)
{
int i, j, k, t;
for (i = 1; i < n; i++)
{
for (j = 0; j < n - i;j++)
if (a[j][M + 2 < a[j + 1][M + 2])
{
for (k = 0; k < M + 3; k++)
{
t = a[j][k];
a[j][k] = a[j + 1][k];
a[j + 1][k] = t;
}
}
}
}
void main()
{
int score[N][M + 3], n;
printf("\nHow many students are there in the class?");
scanf_s("%d", &n);
Input(score, n);
Output(score, n);
Sort(score, n);
Output(score, n);
void Input(int score[][M+3], int n);這是你的第一個函數,親,刪掉分號!