游客 Signup | Login
中文 | En

3038 - 【设计型】第12章:结构体和共同体 例3 嵌套结构体

定义一个学生结构体,数据成员包括学号,姓名,性别,生日。其中生日是一个用来嵌套的结构体,然后输出1个同学的数据。

Input

Output

一行输出一个同学的数据。

Examples

Input

no input needed

Output

1001011 王丽 F 1995/10/12

Solution C

#include<stdio.h> 
struct birthday
{
	int year;
	int month;
	int day;
};
struct student 
{
long num;
char name[20];
char sex;
struct birthday b;	
}; 
int main()
{
	int i;
struct student stu[3]={{1001011,"王丽",'F',{1995,10,12}},
                       {1001012,"李军",'M',{1995,5,24}},
					    {1001013,"赵斌",'M',{1994,2,25}},
               };
			   for(i=0;i<3;i++)
			   {
			   	printf("%ld %s %c %d/%d/%d\n",stu[i].num,stu[i].name,stu[i].sex,
				   stu[i].b.year,stu[i].b.month,stu[i].b.day);
			   }
			   return 0;	
}










Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题