No older revisions available
No older revisions available
~cpp
#include<iostream>
using namespace std;
void output(int board[20][20]);
int main()
{
int board[20][20]={0,};
int x,y;
char input;
cin >> x;
cin >> y;
board[y][x]=1;
while(input!='9')
{
cin >> input;
switch(input)
{
case'0':
board[--y][x]+=1;
break;
case'1':
board[--y][++x]+=1;
break;
case'2':
board[y][++x]+=1;
break;
case'3':
board[++y][++x]+=1;
break;
case'4':
board[++y][x]+=1;
break;
case'5':
board[++y][--x]+=1;
break;
case'6':
board[y][--x]+=1;
break;
case'7':
board[--y][--x]+=1;
}
if(y=20)
y=0;
if(y=-1)
y=19;
if(x=20)
x=0;
if(x=-1)
x=19;
}
output(board);
return 0;
}
void output(int board[20][20])
{
for (int i=0; i<20; i++)
{
for(int j=0; j<20; j++)
{
cout << board[i][j] << " ";
}
cout << endl;
}
}
~cpp
김회영
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
int i=0,j=0;
ifstream fin("input.txt");
int size;
fin>>size;
const int Size=6;
int startx;
fin>>startx;
//const int startX=startx;
int starty;
fin>>starty;
//const int startY=starty;
int array[100][100];
for(int k=0 ; k<Size ; k++)
for(int j=0 ; j<Size ; j++)
array[k][j]=0;
array[0][0]=1;
char Key;
fin>>Key;
while(Key != '9')
{
if(Key=='0')
{
if(j==0)
{
j=Size-1;
array[i][j];
}
(array[i][--j])+=1;
}
else if(Key=='1')
{
if(i==Size-1 && j==0)
{
i=0;
j=Size-1;
array[i][j];
}
(array[++i][--j])+=1;
}
else if(Key=='2')
{
if(i==Size-1)
{
i=0;
array[i][j];
}
(array[++i][j])+=1;
}
else if(Key=='3')
{
if(i==Size-1 && j==Size-1)
{
i=0;
j=0;
array[i][j];
}
(array[++i][++j])+=1;
}
else if(Key=='4')
{
if(j==Size-1)
{
j=0;
array[i][j];
}
(array[i][++j])+=1;
}
else if(Key=='5')
{
if(i==0 && j==Size-1)
{
i=Size-1;
j=0;
array[i][j];
}
(array[--i][++j])+=1;
}
else if(Key=='6')
{
if(i==0)
{
i=Size-1;
array[i][j];
}
(array[--i][j])+=1;
}
else// (key==7)
{
if(i==0 && j==0)
{
i=Size-1;
j=Size-1;
array[i][j];
}
(array[--i][--j])+=1;
}
fin>>Key;
}
for(int m=0 ; m<Size ; m++)
{
for(int j=0 ; j<Size ; j++)
cout<<array[j][m]<<",";
cout<<endl;
}
return 0;
}