No older revisions available
No older revisions available
~cpp
#include<iostream>
#include<string>
using namespace std;
int main()
{
//입력받기기
int start_x = 0;
int start_y = 0;
int width_size = 5;
int length_size = 5;
int road[width_size][length_size]={{0}};
string temp = "2222244451";
int i= start_x;
int j = start_y;
for (int k=0;k<temp.size();k++)
{
switch(temp[k])
{
case 0:
i--;
break;
case 1:
j++;
i--;
break;
case 2:
j++;
break;
case 3:
i++;
j++;
break;
case 4:
i++;
break;
case 5:
i++;
j--;
break;
case 6:
j--;
break;
case 7:
i--;
j--;
}
if (i<0)
i=length_size-1;
if (i>=length_size)
i=0;
if (j<0)
j=width_size-1;
if (j>=width_size)
j=0;
++road[i][j];
}
for(i=0; i<length_size; i++)
{
for(int j=0; j<width_size; j++)
cout<<road[i][j]<<"\t";
cout<<endl;
}
return 0;
}