вот...с горем пополам работает
C++ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
| #include<iostream>
#include<time.h>
using namespace std;
const int n = 5;
int main()
{
int arr[n][n];
int col,num,i,j,num_temp,z;
srand(time(NULL));
for( i=0;i<n;i++) {
for( j=0;j<n;j++) {
arr[i][j]=rand()%4;
cout<<arr[i][j]<<" ";
}
cout<<"\n";
}
num=n*2;
for ( i=0;i<n;i++) {
num_temp=0;
for( j=0;j<n;j++) {
for( z=0;z<n;z++) {
if (arr[j][i]==arr[z][i])
num_temp++;
}
}
if (num_temp<num) {
num=num_temp;
col=i;
}
}
cout<<"Number of column: "<<col+1<<"\n";
system("pause");
} |
|