Răspuns:
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
ifstream in ("strazi.in");
ofstream out ("strazi.out");
double a[105][1005];
double gradMax=0;
int lin = -1;
int main()
{
int n, x=0;
in >> n;
for (int i=1; i<=n; i++)
{
in >> a[i][0];
for (int j=1; j<=a[i][0]; j++)
in >> a[i][j];
}
for (int i=1; i<=n; i++)
{
double max1=a[i][1];
int nr=1;
for (int j=2; j<=a[i][0]; j++)
{
if (a[i][j]>max1)
{
nr++;
max1=a[i][j];
}
}
float grad = (float)nr/a[i][0];
out << fixed << setprecision(3) << grad << '\n';
if (grad>gradMax)
{
gradMax = grad;
lin = i;
}
}
out << lin;
return 0;
}
Explicație: