题目要求为定义一个结构体,向里面输入数据,然后输出,注意定义时输入的数据顺序为 name,roll,marks,输出时顺序为roll,name,marks
#include<stdio.h>
struct student
{
char name
[10];
int roll
;
float marks
;
};
int main(){
struct student stu
[5];
int i
,j
;
for(i
=0;i
<5;i
++){
scanf("%s %d %f",&stu
[i
].name
,&stu
[i
].roll
,&stu
[i
].marks
);
}
struct student
*p
;
for(p
=stu
;p
<stu
+5;p
++){
printf("Roll number: %d\n",p
->roll
);
printf("Name: %s\n",p
->name
);
printf("Marks: %.1f\n",p
->marks
);
}
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-63126.html