/* Note:Your choice is C IDE */
#include "stdio.h"
#define MAX 10
#define Y 1
#define N 0
struct birth {
int year;
int month;
int day;
};
struct stu {
char name[10] ;
long num;
char add[20];
struct birth mybirth;
}student [MAX];
int count = 0, m;
void arr_stu ( struct stu *p_stu , int length );
main()
{ int choice=1;
printf ("please input the infomation about students\n\n");
for (; count < MAX && choice == 1 ; count ++)
{
printf ("\n\n\n\n\ninput the %d student information", count+1);
printf ("\n\n\ninput the name >>");
scanf ("%s",student[count].name);
printf ("\ninput the num >>");
scanf ("%ld",&student[count].num);
printf ("\ninput the birthday ( for example : 1945,4,6) >>");
scanf ("%d,%d,%d",&student[count].mybirth.year , &student[count].mybirth.month , &student[count].mybirth.day );
printf ("\n\n contiue or exit\? (1 means continu ; 0 means exit)");
scanf ("%d",&choice);
m = count;
}
arr_stu ( student , MAX );
printf ("\n\n\n\n");
for (count=0; count <= m ; count ++ )
printf ( "The %d student's name is %s ,num is %ld\n",count+1 , student[count].name, student[count].num);
}
void arr_stu (struct stu *p_stu , int length )
{
struct stu change;
int i=0,j;
for (; i<=m-1 ;i++)
{
for (j=i+1;j<=m;j++)
{
if ( p_stu[i].num > p_stu[j].num)
{ change = p_stu [i];
p_stu[i] = p_stu[j];
p_stu [j] = change;
}
}
}
}