Task is to find the column number(index) that have maximum sum of it's elements
/*Input First line N and M (1<=N,M<=100). Then NxM table is given(all number are integers) Output The index of the column with maximum sum of it's elements. Sample input: 3 4 1 2 3 1 1 5 6 1 1 1 8 1 Sample output: 3 What is wrong ?*/ #include <iostream> using namespace std; int main() { int n, m, i, j, counter = 0; int aza[100][100], max[100], temp; cin >> n >> m; for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { cin >> aza[i][j]; } } for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { if (aza[i][j] > 0) { counter++; aza[i][j] = max[i]; } } } cout << counter << endl; temp = 0; for (i = 0; i < counter; i++) { for (j = i + 1; j < counter; j++) { if (max[i] > max[j]); { temp == max[i]; max[i] = max[j]; max[j] = temp; } } cout << max[i] << " "; } return 0; }