#include<stdio.h>
#define N 4
main()
{
int score[N][4],*pp[N][4];
float average[N],*pa[N];
char *title[]={"学号","姓名","数学","物理","英语","计算机","平均成绩"};
char xuehao[N][10],name[N][8],*px[N],*pn[N];
int k=0,i;
for(;k<N;k++) /* 给指针数组赋予地址空间,既数组所对应的空间 */
{
px[k]=xuehao[k]; /* 学号指针数组 */
pn[k]=name[k]; /* 姓名指针数组 */
pa[k]=&average[k]; /* 平均成绩数组 */
for(i=0;i<4;i++) /* 各科成绩数组指针 */
pp[k][i]=&score[k][i];
}
k=0;
for(;k<N;k++) /* 记录的输入 */
{
printf("\ninput xuehao %d: ",k+1);
scanf("%s",px[k]);
printf("\ninput name %d: ",k+1);
scanf("%s",pn[k]);
printf("\ninput score[%d][0] score[%d][1] score[%d][2] score[%d][3]:",k,k,k,k);
scanf("%d%d%d%d",pp[k][0],pp[k][1],pp[k][2],pp[k][3]);
}
for(k=0;k<N;k++) /* 求平均成绩 */
*pa[k]=(*pp[k][0]+*pp[k][1]+*pp[k][2]+*pp[k][3])/4.0;
printf("\n%-10s%-10s%-6s%-6s%-6s%-8s%-8s",title[0],title[1],title[2],title[3],title[4],title[5],title[6]);
printf("\n------------------------------------------------------");
for(k=0;k<N;k++)
printf("\n%-10s%-8s%4d %4d %4d %6d %7.1f",px[k],pn[k],
*pp[k][0],*pp[k][1],*pp[k][2],*pp[k][3],*pa[k]);
getch();
}