Varooooooooooog in C++
sa aratati cum faci fisierul


Varooooooooooog In C Sa Aratati Cum Faci Fisierul class=

Răspuns :

Răspuns:

#include<iostream>

#include<fstream>

using namespace std;

struct note_purtare {

 int nmatr;

 int nt;

 int nam;

 int np;

}note[30];

int main() {

int i = 0, n;

fstream f("purtare.in");

f >> n;

while (f)

{

 f >> note[i].nmatr;

 f >> note[i].nt;

 f >> note[i].nam;

 f >> note[i].np;

 if (note[i].nt - note[i].nam > 50)

  note[i].np = 4;

 else

  note[i].np = note[i].np - (note[i].nt - note[i].nam) / 10;

 i++;

}

ofstream out("purtare.out");

for (int j = 0; j <= 4 - 1; j++)

 for (int k = j; k < 4; k++)

  if (note[j].np < note[k].np)

   swap(note[j], note[k]);

i= 0;

out << n<<endl;

while (i < n) {

 out << note[i].nmatr << " ";

 out << note[i].nt << " ";

 out << note[i].nam << " ";

 out << note[i].np << " ";

 i++;

 out << endl;

}

}