//Я просто опишу метод записи матрицы const n=100; var ar:array of array of integer; ars:array of array of string; i:integer;
procedure complection(var ar:array of array of integer;var ars:array of array of string); var i,j:integer; begin; for i:=1 to n do begin; for j:=1 to n do begin; ar[i,j]:=random(9); str(ar[i,j],ars[i,j]); end; end; end;
procedure burning(ars:array of array of string); var i,j:integer; t:text; begin; assign(t,'text.txt'); rewrite(t); for i:=1 to n do begin; writeln(t,' '); for j:=1 to n do write(t,ars[i,j],' '); end; end;
begin; randomize; setlength(ar,n+1); setlength(ars,n+1); for i:=1 to n do begin; setlength(ar[i],n+1); setlength(ars[i],n+1); end; complection(ar,ars); burning(ars); end.
#include <cstring>
#include <vector>
#include <algorithm>
struct StudentData
{
std::string name;
std::string surname;
int math;
int phys;
int comp_science;
};
bool
comp(const StudentData &a, const StudentData &b)
{
int tmp1 = a.math + a.phys + a.comp_science;
int tmp2 = b.math + b.phys + b.comp_science;
return tmp1 > tmp2 ? true : false;
}
int
main(void)
{
int n;
std::cin >> n;
std::vector< StudentData > data(n);
for (int i = 0; i < n; i++) {
std::cin >> data[i].name >> data[i].surname;
std::cin >> data[i].math >> data[i].phys >> data[i].comp_science;
}
std::sort(data.begin(), data.end(), comp);
for (int i = 0; i < n; i++) {
std::cout << data[i].name << " " << data[i].surname << std::endl;
}
return 0;
}