
能不能帮忙完成一下这个程序,最主要的问题是,我一但用scanf输入学生的信息,马上就会没有输出结果,这是为什么
供参考:
#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);
/************** End ***********/
/**********交换两个结构体变量s1和s2**********/
/************* Begin ***********/
s3 = s1; s1 = s2; s2 = s3;
/************** End ***********/
/**********输出结构体变量s1和s2的成员*********/
/************* Begin ***********/
printf("学号:%d\n姓名:%s\n性别:%c\n出生日期:%d年%d月%d日\n成绩:%.0f\n", s1.num, s1.name, s1.sex, s1.birth.year, s1.birth.month, s1.birth.day, s1.score);
printf("学号:%d\n姓名:%s\n性别:%c\n出生日期:%d年%d月%d日\n成绩:%.0f\n", s2.num, s2.name, s2.sex, s2.birth.year, s2.birth.month, s2.birth.day, s2.score);
/************** End ***********/
return 0;
}