שפת C/מערכים/תרגילים: הבדלים בין גרסאות בדף
תוכן שנמחק תוכן שנוסף
←הדפסת ערכי מטריצה (מערך דו-מימדי) בצורה מעגלית: בלי קדם מעבד, אבל עימוד גרוע |
|||
שורה 352:
//if we are on the limit: move limit one step to center & change direction
if(x==u)
{
u++;
dir=(dir+1)%4;
}
}
else if (dir == RIGHT)
{
//move to direction
y++;
//if we are on the limit: move limit one step to center & change direction
if(y==r)
r--;
dir=(dir+1)%4;
}
}
else if(dir == DOWN)
{
//move to direction
x++;
//if we are on the limit: move limit one step to center & change direction
if(x==d)
{
d--;
dir=(dir+1)%4;
}
}
else if(dir == LEFT)
{
//move to direction
y--;
//if we are on the limit: move limit one step to center & change direction
if(y==l)
{
l++;
dir=(dir+1)%4;
}
}
▲ }
}
return 0;
|