练习40
点击蓝字
关注我们
DRAGON BOAT FESTIVAL
练习40
01 要求:
用指针变量输出结构数组
02 程序示例如下:
//用指针变量输出结构数组
struct stu
{
int num;
char *name;
char sex;
float score;
}boy[5] = {
{ 101, "Zhou ping", 'M', 45 },
{ 102, "Zhang ping", 'M', 62.5 },
{ 103, "Liou fang", 'F', 92.5 },
{ 104, "Cheng ling", 'F', 87 },
{ 105, "Wang ming", 'M', 58 },
};
int main()
{
struct stu *ps;
printf("No\tName\t\t\tSex\tScore\t\n");
for (ps = boy; ps<boy + 5; ps++)
printf("%d\t%s\t\t%c\t%f\t\n", ps->num,
ps->name, ps->sex, ps->score);
return 0;
}
03:输出:
No Name Sex Score
101 Zhou ping M 45.000000
102 Zhang ping M 62.500000
103 Liou fang F 92.500000
104 Cheng ling F 87.000000
105 Wang ming M 58.000000
球分享
球点赞
球在看
评论