The file rezultati.txt just have the "Konecni rezultati po predmetot Osnovi na programiranje" why? help



#include <fstream>
#include <iostream>



using namespace std;

class Student {
public:
int index;
int kolokvium1;
int kolokvium2;
int vkupno;
int ocena;
};

int poeni2ocena(int poeni){

if( poeni > 90 ){
return 10;
}

if ( poeni > 80 ){
return 9;
}

if( poeni > 70 ){
return 8;
}

if( poeni > 60 ){
return 7;
}

if( poeni > 50 ){
return 6;
}

return 5;

} // poeni2ocena()

int main(){

ifstream fin("Poeni.txt");

int count = 0; // count of items in student array
Student students[100];
do
{

Student student ;
fin >> student.index >> student.kolokvium1 >> student.kolokvium2 ;

student.vkupno = student.kolokvium1 + student.kolokvium2;
student.ocena = poeni2ocena(student.vkupno);

for( int i = 0; i < count; i++ ){

// find the place to insert the student while
// keeping the students array sorted
if( student.vkupno > students[i].vkupno ){

// push all the remaining students by one
for( int j = count; j > i; j-- ){
students[j] = students[j-1];
}

// and insert the new one
students[i] = student;

// increase the students counter
count++;

// done with this student, break the check and get a new one
break;

} // if

} // for i

}while( !fin.eof() ); // while ! fin.eof()

fin.close();


// print the sorted students array into the file
ofstream fout;
fout.open("Rezultati.txt");

fout << "Konecni rezultati po predmetot Osnovi na programiranje" << endl;

for( int i = 0; i < count; i++ )
{
fout << students[i].index<<" "<< students[i].vkupno <<" "<< students[i].ocena << endl;
}


fout.close();

return 0;

} // main
[code] "Please use code tags" [/code]
1
2
3
4
5
6
7
8
int count = 0;
for( int i = 0; i < count; i++ ){ //never gets inside
  //...
  if( student.vkupno > students[i].vkupno ){
  //...
    count++; //never executes
  }
}
Topic archived. No new replies allowed.