#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
int max1 = 0;
int max2 = 0;
int max3 = 0;
int arr[3][4] = { {59,66,78,98},{64,85,76,90},{9,95,95,96} };//定义一个三行四列的数组
printf("张三成绩:\n");
printf("语文\t数学\t英语\t道德\n");
for (int i = 0; i < 4; i++)
{
printf("%-2d\t ",arr[0][i]);
}
printf("\n");
printf("李四成绩:\n");
printf("语文\t数学\t英语\t道德\n");
for (int i = 0; i < 4; i++)
{
printf("%-2d\t ", arr[1][i]);
}
printf("\n");
printf("王二成绩:\n");
printf("语文\t数学\t英语\t道德\n");
for (int i = 0; i < 4; i++)
{
printf("%-2d\t ", arr[2][i]);
}
for (int i = 0; i < 4; i++)
{
if (arr[0][i] > arr[0][i + 1])
{
max1 = arr[i][i];
}
}
for (int i = 0; i < 4; i++)
{
if (arr[1][i] > arr[1][i + 1])
{
max2 = arr[1][i];
}
for (int i = 0; i < 4; i++)
{
if (arr[2][i] > arr[2][i + 1])
{
max3 = arr[2][i];
}
}
}
printf("\n");
int max4 = (max1 > max2) ? max1 : max2;
int MAX = (max3 > max4) ? max3 : max4;
printf("最高成绩:%d\n",MAX);
int yuwen = 0;
for (int i = 0; i < 3; i++)
{
yuwen += arr[i][0];
}
int math = 0;
for (int i = 0; i < 3; i++)
{
math += arr[i][1];
}
int english = 0;
for (int i = 0; i < 3; i++)
{
english += arr[i][2];
}
int daode = 0;
for (int i = 0; i < 3; i++)
{
daode += arr[i][2];
}
printf("语文平均成绩:%d\n", yuwen/3);
printf("数学平均成绩:%d\n", math/3);
printf("英语平均成绩:%d\n", english/3);
printf("道德平均成绩:%d\n", daode/3);
int arvage_zs=0;
for (int i = 0; i < 4; i++)
{
arvage_zs += arr[0][i];
}
printf("张三总平均成绩:%d\n",arvage_zs/4);
int arvage_ls = 0;
for (int i = 0; i < 4; i++)
{
arvage_ls += arr[1][i];
}
printf("李四总平均成绩:%d\n", arvage_ls/4);
int arvage_we = 0;
for (int i = 0; i < 4; i++)
{
arvage_we += arr[1][i];
}
printf("王二总平均成绩:%d\n",arvage_we/4);
return 0;
}
标签:arr,arvage,各门,int,++,课程,printf,成绩
From: https://blog.51cto.com/u_16425777/8946897