👤

Program in Cpp cu folosirea subprogramelor

Program In Cpp Cu Folosirea Subprogramelor class=

Răspuns :

Răspuns:

minimul pe coloana e aflat cred altfel decat in enunt... dar cred eficient

Explicație:

#include <iostream>

#include <fstream>

using namespace std;

ifstream f("var31.in");

ofstream g("var31.out");

int n,m,i,j,num,col[100];

void minim(int num, int &k)

{

   if (num<k) k=num;

}

int maxim(int m, int col[])

{

   int x=col[1];

   for (int j=2; j<=m; ++j)

       x=max(x,col[j]);

   return x;

}

int main()

{

   f >> n >> m;

   for (j=1; j<=m; ++j)

       f >> col[j];

   for (i=2; i<=n; ++i)

   {

       for (j=1; j<=m; ++j)

       {

           f >> num;

           minim(num,col[j]);

       }

   }

   g << maxim(m,col);

}