lt61601.c
来自「陈孟建等编著的C语言教程附带光盘」· C语言 代码 · 共 33 行
C
33 行
#define N 30
# include"stdlib.h"
# include "stdio.h"
struct stud_type
{ char name[9];
long num;
int age;
float score;
};
void main()
{ void disp(struct stud_type *p);
struct stud_type student[N];
int i;
char numstr[9];
for (i=0;i<N;i++)
{ printf ("\n请输入所有的数据student[%d]:\n",i);
gets(student[i].name);
gets(numstr);
student[i].num=atol(numstr); /* atol功能是将numstr字符转换成长整型值 */
gets(numstr);
student[i].age=atoi(numstr); /* atoi功能是将numstr字符转换成整型值 */
gets(numstr);
student[i].score=atof(numstr); /* atof功能是将numstr字符转换成实型值 */
}
printf("\n 姓名\t\t 学号 年龄 成绩 \n");
for (i=0;i<N;i++)
disp(&student[i]); /* 调用disp函数 */
}
void disp(struct stud_type *p) /* 定义disp函数 */
{ printf("%-9s% 8ld% 3d % 6.2f\n",p->name,p->num,
p->age,p->score);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?