问题1:格式符对应不正确造成输出有问题void showStudentsInformation(struct STI *s, int Cnt) printf("当前学生信息共%d人,信息分别如下:\n", Cnt); for(i = 0; i < Cnt; i++) void main(void) 结果如下: |
问题2:输出对不齐void showStudentsInformation(struct STI *s, int Cnt) printf("\n当前学生信息共%d人,信息分别如下:\n", Cnt); printf("%8s %20s %4s %4s %4s\n", "学号", "姓名", "性别", "年纪", "分数"); //对齐形式 for(i = 0; i < Cnt; i++) printf("%8s %20s %4s %4d %.1lf\n", s[i].id, s[i].name, (s[i].sex == 'm' ? "男" : "女"), s[i].age, s[i].score); //对齐形式 void main(void) 输出结果如下: |
问题3:自己思路和老师思路不同出现的问题
void showStudentsInformation(struct STI *s, int Cnt) printf("\n当前学生信息共%d人,信息分别如下:\n", Cnt); //printf("%8s %20s %4s %4d %.1lf\n", s[i].id, s[i].name, (s[i].sex == 'm' ? "男" : "女"), s[i].age, s[i].score); //老师正确形式 //错误原因:指针一直指向同一个数组,故输出只能是同一个数组,没有进行指针的移位 //和老师方法的区别:老师是用数组表示的,而自己是用指针方式表示的 void main(void)
|