新手提问,请各路在侠相助!
我抄了一例,如下:
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++)
{ printf("the %d time",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 maxinum score:\n");
printf("NO.:%d\nname:%s\nscore:%4.1f\n",p->num,p->name,(*p).score);
}
但是为什么不能输入?
我是这样输入的
101(空格)Li(空格)90(回车) 然后出错跳出!
为什么不能向书上那样
运行情况如下:
101 li 90(是个箭头,应该是回车吧)
102 Tan 98(回车)
103 Wang 67(回车)
104 Fun 89(回车)
The maxinum score;
No.:102
name:Tan
score:98.0