游客 Signup | Login
中文 | En

3045 - 【设计型】第12章:结构体与共同体 例7 向函数传递结构体(2)

定义一个学生结构体,数据成员包括学号,姓名,性别,生日(年月日),然后编写一个输出函数输出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;	
}; 
void display (struct student *pt)
{
			   	printf("%ld %s %c %d/%d/%d\n",pt->num,pt->name,pt->sex,
				   pt->year,pt->month,pt->day);	
}
int main()
{
struct student stu={1001011,"王丽",'F',1995,10,12        
               };
               struct student *p=&stu;
              display(p); 
			   return 0;	
}
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题