C++6.0结构体练习!!!

来源:百度知道 编辑:UC知道 时间:2024/06/23 15:57:50
定义student结构体,student中包含num(学号)、name(姓名)、date结构体变量birthday(包括year、month、day),请输入5个学生信息,按年龄由小到大顺序输出这五个学生的姓名。

用结构体来做,必有追加!!!
要求:
1、排序用sort函数实现(选择法实现)
2、sort函数参数是指针变量。

#include<iostream>
using namespace std;
struct student
{
int num;
char name[20];
char date;
};
struct date
{
int year;
int month;
int day;
};
student1,student2,student3,student4,student5;
{
void select_sort(int array[],int n);
int a[5],i;
cout<<
for(i=0;i<10;i++)
cin>>a[5];
cout<<endl;
select_sort(a,10);
cout<<"enter the orginl array:"<<endl;
for(i=0,i<5;i++)
cout<<a[5]<<"";
cout<<endl;
return a
}

怎么改?

typedef struct
{
int year;
int month;
int day;
}Date; /* 大写以便与变量名区别开来 */
typedef struct
{
int num;
char name[20];
Date birthday;
}Student;

下面的太乱了,都不知道哪部分属于什么函数

代码太长了……略

这个还真难啊.