游客 Signup | Login
中文 | En

3042 - 【设计型】第12章:结构体和共同体 例5 结构体指针的定义和初始化

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

注:要求使用结构体指针访问数据成员。

Input

Output

输出一组数据

Examples

Input

no input needed

Output

1001011 王丽 F 1995/10/12

Solution C

#include<stdio.h> 
typedef struct student 
{
long num;
char name[20];
char sex;
int year;
int month;
int day;	
}STU; 
int main()
{
	int i;
STU *p;	 
STU stu={1001011,"王丽",'F',1995,10,12
               };
               p=&stu;
			   	printf("%ld %s %c %d/%d/%d\n",p->num,p->name,p->sex,
				   p->year,p->month,p->day);
			   return 0;	
}

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