// PascalABC.NET 3.3, сборка 1576 от 16.11.2017 // Внимание! Если программа не работает, обновите версию!
begin var V:=MatrRandom(7,7,-15,15);v.Println; var com:= V.Row(2).Aggregate(BigInteger(1),(x,y)->(x*y)); Writeln('Произведение эл-в 3ей строки = ', com); var cnt := 0; Foreach var x in V.Row(2) do if x > com then inc(cnt); Writeln('Количество элементов, больших чем это произведение = ', cnt); Writeln('Максимальный элемент 3го столбца = ', V.Col(2).Max); end.
Пример: 2 -4 -15 10 -1 2 6 15 -8 11 5 14 10 15 0 15 -10 13 -8 -13 14 14 6 13 -10 9 6 -12 -14 1 8 -9 1 -12 12 15 9 10 -7 -14 6 -3 9 9 -1 -14 1 1 3 Произведение эл-в 3ей строки = 0 Количество элементов, больших чем это произведение = 3 Максимальный элемент 3го столбца = 13
#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;
}