Skip to content

Instantly share code, notes, and snippets.

@gupta-shrinath
Created September 22, 2021 08:25
Show Gist options
  • Save gupta-shrinath/57ea4773d0807d973b4f85cddc778efe to your computer and use it in GitHub Desktop.
Save gupta-shrinath/57ea4773d0807d973b4f85cddc778efe to your computer and use it in GitHub Desktop.
#include <stdio.h>
int maxOneRow(int array[][16],int r,int c) {
int currentRowCounter=0;
int maxOneRow = 0;
int maxRowCounter = 0;
int i=0,j = 0;
for(i;i<r;i++) {
for(j;j<c;j++) {
if(array[i][j]==1) {
currentRowCounter++;
}
}
if(currentRowCounter>=maxRowCounter) {
maxRowCounter = currentRowCounter;
maxOneRow = i;
}
j=0;
currentRowCounter=0;
}
return maxOneRow;
}
void main() {
int r,c = 0;
scanf("%d",&r);
scanf("%d",&c);
int i=0,j=0;
int a[r][c];
for(i;i<r;i++){
for(j;j<c;j++) {
scanf("%d",&a[i][j]);
}
j=0;
}
int value = maxOneRow(a,r,c);
printf("%d",value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment