#include<iostream.h>
#include<conio.h>
#include<fstream.h>
void main()
{
                int i,j,temp;
                int rn[10],reg[10],tm[10],s1,s2,s3;
                clrscr();
                ifstream identify("identify.txt");
                ifstream marks("marks.txt");
                ofstream ascend("ascend.txt");
                ofstream descend("descend.txt");
                for(i=0;i<10;i++)
                                {
                                identify>>rn[i]>>reg[i];
                                marks>>s1>>s2>>s3;
                                tm[i]=s1+s2+s3;
                                }
                for(i=0;i<9;i++)
                                for(j=i+1;j<10;j++)
                                                if(tm[j]<tm[i])
                                                                {
                                                                temp=tm[j]; tm[j]=tm[i]; tm[i]=temp;
                                                                temp=rn[j]; rn[j]=rn[i]; rn[i]=temp;
                                                                temp=reg[j]; reg[j]=reg[i]; reg[i]=temp;
                                                                }
                for(i=0;i<10;i++)
                                ascend<<rn[i]<<"\t"<<reg[i]<<"\t"<<tm[i]<<endl;
                for(i=0;i<9;i++)
                                for(j=i+1;j<10;j++)
                                                if(tm[j]>tm[i])
                                                                {
                                                                temp=tm[j]; tm[j]=tm[i]; tm[i]=temp;
                                                                temp=rn[j]; rn[j]=rn[i]; rn[i]=temp;
                                                                temp=reg[j]; reg[j]=reg[i]; reg[i]=temp;
                                                                }
                for(i=0;i<10;i++)
                                descend<<rn[i]<<"\t"<<reg[i]<<"\t"<<tm[i]<<endl;
                identify.close();
                marks.close();
                ascend.close();
                descend.close();
                getch();
}

 

Advertisements