Created
September 22, 2021 08:25
-
-
Save gupta-shrinath/57ea4773d0807d973b4f85cddc778efe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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