You are on page 1of 2

#include <iostream>

using namespace std;

int main() {

int m, n;

cout << "Enter m and n (m, n < 10): ";

cin >> m >> n;

int arr[10][10];

cout << "Enter the elements of the twoside array:\n";

for (int i = 0; i < m; i++) {

for (int j = 0; j < n; j++) {

cin >> arr[i][j];

int maxUnique = 0, columnIndex = -1;

for (int j = 0; j < n; j++) {

bool seen[10];

fill(seen, seen + 10, false);

int unique = 0;

for (int i = 0; i < m; ++i) {

if (!seen[arr[i][j]]) {

unique++;

seen[arr[i][j]] = true;

}
if (unique >= maxUnique) {

maxUnique = unique;

columnIndex = j;

cout << "Column with the most unique numbers: " << columnIndex + 1 << endl;

return 0;

You might also like