结构体,对例题的总结

/*  
*Copyright (c) 2013 ,烟台大学计算机学院  
*All rights reserved.  
*作者:王至超  
*完成日期:2014.02.26 
*版本号:v1.0  
*问题描述:利用结构体复习课本例题 
*样例输入: 
*样例输出: 
*问题分析:用简单的方法,学会活学活用  
*/  
#include <iostream>
using namespace std;
struct Date//声明结构体类型Date
{
    int month;
    int day;
    int year;
};
struct Student//声明结构体类型Student
{
    int num;
    char name[20];
    char sex;
    Date birthday;
    float score;
}student1,student2={10002,"Wang Li",'f',5,23,1992,89.5};
int main()
{
   student1=student2;
   cout<<student1.num<<endl;
   cout<<student1.name<<endl;
   cout<<student1.sex<<endl;
   cout<<student1.birthday.month<<'/'<<student1.birthday.day<<"/" <<student1.birthday.year<<endl;
   cout<<student1.score<<endl;
    return 0;
}
结构体,对例题的总结_第1张图片

你可能感兴趣的:(结构体,对例题的总结)