Skip to content

Instantly share code, notes, and snippets.

Created December 5, 2013 04:43
Show Gist options
  • Save anonymous/7800255 to your computer and use it in GitHub Desktop.
Save anonymous/7800255 to your computer and use it in GitHub Desktop.
#include "stdafx.h"
#include <iomanip>
#include <iostream>
using namespace std;
const int n=6;
const int m=6;
struct funk
{
int kolvo;
int numb;
};
void zap(int **mas, int n, int m)
{
for(int i=0; i<=n-1; i++)
{
for(int k=0; k<=m-1; k++)
{
mas[i][k]=(rand()%9)+1;
}
}
}
void printm(int **mas, int n, int m)
{
for(int i=0; i<=n-1; i++)
{
for(int k=0; k<=m-1; k++)
{
cout<<mas[i][k]<<" ";
}
cout<<endl;
}
}
void result (int**mas, int n, int m, funk *mas2)
{
int min, k=0, g=0;
for(int i=0; i<=n-1; i++)
{
min=mas[i][0];
for(int k=0; k<=m-1; k++)
{
if (mas[i][k]<min)
{
min=mas[i][k];
}
}
mas2[g].kolvo=min;
mas2[g].numb=i;
g++;
}
cout<<endl;
for(int i=0; i<=g-1; i++)
{
cout<<mas2[i].numb<<" ";
}
cout<<endl;
for(int i=0; i<=g-1; i++)
{
cout<<mas2[i].kolvo<<" ";
}
}
int _tmain(int argc, _TCHAR* argv[])
{
setlocale(LC_ALL, "Rus");
srand(time(0));
funk *mas2;
mas2=new funk[n*m];
int **mas;
mas=new int*[n];
for(int i=0; i<=n-1; i++)
{
mas[i]=new int[m];
}
zap(mas,m,n);
printm(mas,m,n);
result(mas,m,n,mas2);
cin.get();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment