各位这个结构体输出有什么问题呢

毕设工坊 课程设计 1

回复

共1条回复 我来回复
  • 源码客栈
    这个人很懒,什么都没有留下~
    评论
    #include<stdio.h>
    struct stu
    {
        int num;
        char name[20];
        char sex;
        float score;
    }boy[5] = {
        {1,"a",'m',100},
        {2,"b",'m',80},
        {3,"c",'m',60},
        {4,"d",'m',40},
        {5,"e",'m',20},
    };
    int main()
    {
        struct stu *ps;
        printf("NO\tName\tSex\tScore\n");
        for (ps = boy; ps < boy + 5; ps++)
        {
            printf("%d\t", ps->num);
            printf("%s\t", ps->name);
            printf("%c\t", ps->sex);
            printf("%f\n", ps->score);
        }
    }
    
    0条评论

发表回复

登录后才能评论