大家晚上好,我潭的书看到结构体了,这个是例题,我调了好半天,编译都可以可运行结果就是出不来,出学望高手指点,万分感谢啊
#include "stdio.h"
#include "string.h"
main()
{
struct student
{
int num;
char name[20];
float score;
};
struct student stu[4];
struct student *p;
int i,temp=0;
float max;
for(i=0;i<4;i++)
scanf("%d%s%f",&stu[i].num,stu[i].name,&stu[i].score);
for(max=stu[0].score,i=1;i<4;i++)
if(stu[i].score>max)
{
max=stu[i].score;
temp=i;
}
p=stu+temp;
printf("\nThe maximum score:\n");
printf("No.:%d\nname:%s\nscore:%4.1f\n",p->num,p->name,p->score);
getch();
}