Răspuns :
movie.h:
#include <string>
struct Movie {
std::string titlu;
int anulAparitiei;
int boxOffice;
int rottenRating;
};
void PrintItem(Movie &item);
movie.cpp:
#include "movie.h"
#include <iostream>
using namespace std;
void PrintItem(Movie &item){
cout << item.titlu << ' ' << item.anulAparitiei << ' ' << item.boxOffice << ' ' << item.rottenRating << '\n';
}
main.cpp:
#include "movie.h"
#include <iostream>
#include <algorithm>
using namespace std;
Movie tablou[10000];
int main(){
int n;
cin >> n;
for(int i = 0; i < n; i++){
cin >> tablou[i].titlu >> tablou[i].anulAparitiei >> tablou[i].boxOffice >> tablou[i].rottenRating;
}
sort(tablou, tablou+n, [](Movie a, Movie b)->bool
{
return a.boxOffice > b.boxOffice;
});
for_each(tablou, tablou+n, [](Movie m)
{
PrintItem(m);
}
);
}