EDIT: Problem is solved thank you all. I know the problem is not very well explained, sorry for that.
#include <stdio.h>
int main()
{
int line=0;
int longest=0;
int v1[3][3]={{1,0,0},{1,1,1},{7,8,9}};
for(int i=0 ; i<3;i++){
for(int j=0; j<2 ;j++ ){
if(v1[i][j]==0){
int temp=1;
for(int k=j+1; k< 3; k++){
printf("%d\n",k);
if( v1[i][k]==0 ){
temp++;
}
if( v1[i][k]=!0 ){
if( temp>longest ){
longest=temp;
line=i+1;
}
}
}
}
}
}
printf("line:%d\nlenght:%d",line,longest);
}
I have a code like this. When I try to use else statement with if statement, else statement won't work when the requirements inside if statement are not met.
if( v1[i][k]==0 ){
temp++;
}
else{
if( temp>longest ){
longest=temp;
line=i+1;
}
But when I use another if statement it would run when v1[i][k]!=0 condition is met.
if( v1[i][k]==0 ){
temp++;
}
if( v1[i][k]!=0 ){
if( temp>longest ){
longest=temp;
line=i+1;
}