Help please sort by date of birth. I managed to sort only by year, but I need by date of birth.
#include <math.h> #include <string.h> #include <tchar.h> #include <conio.h> #include <locale> #include <stdio.h> #include <iostream> using namespace std; struct student_list { char first_name[15]; char second_name[15]; char two_name[15]; struct { unsigned int day,month,year; } brithday; }; int main() { FILE *input, *output; int i,n=5; char s[255]; struct student_list bd [10]; student_list sort[10]; input=fopen("test.txt","r"); i=0; while(i<n) { fscanf(input,"%s",&bd[i].first_name); fscanf(input,"%s",&bd[i].second_name); fscanf(input,"%s",&bd[i].two_name); fscanf(input,"%d",&bd[i].brithday.day); fscanf(input,"%d",&bd[i].brithday.month); fscanf(input,"%d",&bd[i].brithday.year); i++; } setlocale(LC_ALL,"Russian"); cout<<"\tСписок группы:"<<endl; cout<<"--------------------------------------------------------------------------------"<<endl; setlocale(LC_ALL,"Russian"); for(i=0;i<n;i++) { cout<<"№ "<<i+1<<"| Ф.И.О. студента: ";setlocale(LC_ALL,"Russian"); cout<<bd[i].second_name<<" "<<bd[i].first_name<<" "<<bd[i].two_name;setlocale(LC_ALL,"Russian"); cout<<"|Дата рождения: "<<bd[i].brithday.day<<"/"<<bd[i].brithday.month<<"/"<<bd[i].brithday.year<<"|"<<endl; } cout<<"------------------------------------------------------------------------------"; for (i=0;i<n-1;i++) { for (int g=i+1;g<n;g++) { if(bd[i].brithday.year>bd[g].brithday.year) { sort[1]=bd[i]; bd[i]=bd[g]; bd[g]=sort[1]; } } } cout<<"\tСписок группы упорядоченный по возрастанию году рождения :"<<endl; cout<<"--------------------------------------------------------------------------------"<<endl; setlocale(LC_ALL,"Russian"); for(i=0;i<n;i++) { cout<<"№ "<<i+1<<"| Ф.И.О. студента: "; setlocale(LC_ALL,"Russian"); cout<<bd[i].second_name<<bd[i].first_name<<bd[i].two_name; setlocale(LC_ALL,"Russian"); cout<<"|Дата рождения: "<<bd[i].brithday.day<<"/"<<bd[i].brithday.month<<"/"<<bd[i].brithday.year<<"|"<<endl; } cout<<"------------------------------------------------------------------------------"; _getch(); }