请编写程序将一个学生的信息初始化,另一个学生的信息从键盘输入,然后交换两个学生的信息,再输出交换后学生的信息。
#include<stdio.h>
#include<string.h>
struct date
{
int year;
int month;
int day;
};
struct stu
{
int num;
char name[20];
char sex;
struct date birth;
float score;
};
int main()
{
struct stu s1 = {10010,"zhangsan",'m',2000,5,4,84.5}, s2, s3;
/*****输入学生信息存放在变量s2中*****/
/********** Begin **********/
scanf("%d %s %c %d %d %d %f",&s2.num,s2.name,&s2.sex,&s2.birth.year,&s2.birth.month,&s2.birth.day,&s2.score);
printf("学号:%d\n姓名:%s\n性别:%c\n出生日期:%d年%d月%d日\n成绩:%.1f\n",s2.num,s2.name,s2.sex,s2.birth.year,s2.birth.month,s2.birth.day,s2.score);
printf("学号:%d\n姓名:%s\n性别:%c\n出生日期:%d年%d月%d日\n成绩:%.1f\n",s1.num,s1.name,s1.sex,s1.birth.year,s1.birth.month,s1.birth.day,s1.score);
return 0;
}