标题:
C语言经典算法之数据结构3
[打印本页]
作者:
苹果也疯狂
时间:
2014-5-26 17:02
标题:
C语言经典算法之数据结构3
#include <stdio.h>
void main()
{
struct childrec /*
定义结构类型
childrec */
{
char initial; /*
姓名首字母
*/
int age; /*
年龄
*/
int grade; /*
考试成绩
*/
};
struct childrec kids[12] = /*
定义
childrec
结构体数组并初始化
*/
{
{'A',16, 80},
{'B',13, 80},
{'C',19, 84},
{'D',19, 89},
{'E',12, 84},
{'F',17, 82},
{'G',16, 90},
{'H',16, 85},
{'I',16, 96},
{'J',17, 91},
{'K',13, 72},
{'L',14, 69}
};
int index;
for (index = 0;index < 12;index++)
printf("%c is %d years old and got a grade of %d\n",
kids[index].initial, kids[index].age,kids[index].grade);
}
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/)
Powered by Discuz! 7.0.0