Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <fstream>
- #include <cstring>
- using namespace std;
- ifstream in("francesca.in");
- struct tampit{
- char nume[30], pre[30];
- int nr_note, medie;
- char corigent[9];
- }x[30];
- int main()
- {
- int nota, i=0;
- while(!in.eof())
- {
- in >> x[i].nume >> x[i].pre;
- strcat(x[i].nume, " ");
- strcat(x[i].nume, x[i].pre);
- x[i].nume[strlen(x[i].nume)-1]=0;
- char c=0;
- while(c!='\n')
- {
- in >> nota >> c;
- x[i].medie+=nota;
- x[i].nr_note++;
- }
- x[i].medie/=x[i].nr_note;
- i++;
- if(x[i].medie<5)
- strcpy(x[i].corigent, "Corigent");
- else
- strcpy(x[i].corigent, "Promovat");
- }
- int n=i;
- for(int i=0; i<n-1; i++)
- {
- for(int j=i+1; j<n; j++)
- {
- if(x[i].medie<x[j].medie)
- {
- swap(x[i], x[j]);
- }
- }
- }
- printf("+----------------------+-------+----------+\n");
- printf("| NUMELE Si Prenumele | Medie | Situatie |\n");
- printf("+----------------------+-------+----------+\n");
- for(int i=0; i<n; i++)
- {
- printf("| %-20s | %2d | %s |\n", x[i].nume, x[i].medie, x[i].corigent);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement