发布网友 发布时间:2022-04-23 06:22
共1个回答
热心网友 时间:2023-08-23 22:07
#include <stdio.h>
struct student
{
int tNum;
char tName[10];
float score[3];
};
void Input( struct student *h, int n)
{
h=NULL;
student *p;
for(int i=0;i<n;i++)
{
p=malloc(sizeof(student));
scanf("%d%s",&(p->tNum),&(p->tName));
for(int i=0;j<3;j++)
scanf("%f",&(p->score[j]));
if(i==0)
h=p;
p++;
}
}
void Total1( struct student *p, int *psum, float *pave, int n)
{
for(int i=0;i<n;i++)
{
*psum=0;
for(int j=0;j<3;i++)
*psum=*psum+p->score[j];
*pave=*psum/3;
psum++;
pave++;
p++;
}
}
void Print( struct student *p, int *psum, float *pave, int n);
{
int i=0,j;
printf( "Pos\tNum\tName\t\tEng\tCom\tMath\tSum\tAver\n");
for(i=0;i<n;i++)
{
printf( "%d\t%ld\t%s\t",i,p->tnum,p->tname);
for(j=0;j<3;j++)
printf("%d\t",p->score[j]);
print("%d\t%.1f\n",*psum,*ave);
p++;
psum++;
pave++;
}
}