Я хочу прервать внутренний цикл и увеличить значение x
, если я найду что-то в Matrix[x][y]
, но если я сломаю y for loop
, оно просто увеличит значение y loop
, а не x loop
.
int matrix[5][5]; //let's assume there are values inside
for(int i = 0; i < 5; i++)
{
for(int j = 0; j<5;j++)
{
int radius = 1;
for(int x = radius - 1; x <= radius + i; x ++)
{
for(int y = radius -1; y <= radius +j; y++)
{
if((x+i) >= 0 && (y+j)>=0)
{
//for example I find the number 45 in the matrix, then the search radius should be increased by 1 and start it over again.
if(matrix[x][y] == 45)
{
radius++;
break; // but if i break here the x value wont be changed
}
}
}
}
}
goto
- person DaBler   schedule 15.03.2018continue
? - person king_nak   schedule 15.03.2018x
передbreak
. - person Peter   schedule 15.03.2018goto
. На самом деле нет другого способа вырвать частично из вложенного цикла без добавления кода проверки на уровень, на который вы хотите выйти. (Логические флаги, числовые проверки и т. Д.) - person Arnav Borborah   schedule 15.03.2018return
. - person StoryTeller - Unslander Monica   schedule 15.03.2018