#include<stdio.h> #include<string.h> #define count_course 3 typedef struct { char num[10]; char name[10]; int grade[count_course]; } Student; Student* input(int std_num) { int i,j; Student *ptr; //定义结构体指针 static Student std[100]; for(i=0;i<std_num;i++) { scanf("%s%s",&std[i].num,&std[i].name); for(j=0;j<count_course;j++) { scanf("%d",&std[i].grade[j]); } } ptr = std; return ptr; } int print(Student *ptr,int std_num) { int i,j; for(i=0;i<std_num;i++) { printf("%s,%s",(ptr+i)->num,(ptr+i)->name);//访问std[i]结构体 for(j=0;j<count_course;j++) { printf(",%d",(ptr+i)->grade[j]); } printf("\n"); } } int main() { int N; Student *pStruct; scanf("%d",&N); pStruct = input(N); print(pStruct,N); return 0; }
0.0分
0 人评分
【回文数(二)】 (C语言代码)浏览:851 |
字符串输入输出函数 (C++代码)(都当成字符串吧hhhhhhhh)浏览:493 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:509 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:534 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:373 |
WU-字符串比较 (C++代码)浏览:754 |
C语言程序设计教程(第三版)课后习题7.2 (C语言代码)浏览:534 |
【计算直线的交点数】 (C语言代码)浏览:1440 |
愚蠢的摄影师 (C++代码)浏览:932 |
简单的a+b (C语言代码)浏览:478 |