Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   could anybody help (http://www.go4expert.com/forums/could-anybody-help-t7217/)

00vampire 7Nov2007 22:45

could anybody help
hello everybody ,,
iam new in this forum and new in C++
so iam starting with problem here if anyone could help

i have file which is contain of name, ID ,Marks and i want to sort it ascending by the Marks
so i dont know how to move the names and Ids when i move the move the marks so could anybody help
""i think maybe if i use another array and use it as index or sth like this but i couldnt figure it out""

and this is my code

#include <iostream.h>
#include <fstream.h>

struct sort
        char names [20];
        long ids;
        int marks;
        int temp;
sort nafek [5],index[5];
fstream  file;
for (int i=0;i<3;i++)

file>>nafek [i].ids>>nafek[i].marks>>nafek[i].names;

for (i=0;i<3;i++)
        for (int j=i+1;j<=3;j++)
                if (nafek[j].marks<nafek[i].marks)
for (i=0;i<3;i++)

cout<<nafek[i].marks<<" "<< nafek[i].names<<nafek[i].ids<<'/n';
        return 0;

and tanx :)

All times are GMT +5.5. The time now is 18:27.