游客 Signup | Login
中文 | En

3039 - 【设计型】第12章:结构体与共同体 例1 定义和初始化结构体

定义一个学生结构体,数据成员包括学号,姓名,性别,生日(年月日),然后输出1个同学的数据。

Input

Output

输出一个同学的数据。

Examples

Input

no input needed

Output

1001011 王丽 F 1995/10/12

Solution C

#include<stdio.h> 
struct student 
{
long num;
char name[20];
char sex;
int year;
int month;
int day;	
}; 
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].year,stu[i].month,stu[i].day);
			   }
			   return 0;	
}


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