U E D R , A S I H C RSS

Scheduled Walk/유주영

No older revisions available

No older revisions available



~cpp 
#include <iostream>
#include <fstream> 
#include <string>
using namespace std; 

int main() 
{ 
	//ifstream fin("input.txt"); // fin과 input.txt를 연결  
	// ofstream fout("output.txt"); // fout과 output.txt를 연결 
	
	int box[15][15]={0};
	string road; 
	cin >> road; // cin으로 화면에서 입력받는다면, fin은 연결된 파일로부터 입력받는다. 
	// 시작점 [8][8]
	int x=7;
	int y=7;
	for(int i=0;i<road.size();i++)
	{
		switch(road[i])
		{	case '1' :	{	
			box[x-1][y+1]++;
			x=x-1;
			y=y+1;
			break;} 
		case '2' :{	box[x][y+1]++;
			
			y=y+1;
			break;}	
		case '3' :{	box[x+1][y+1]++;
			x=x+1;
			y=y+1; break; }	
		case '4' :{	box[x+1][y]++;
			x=x+1;
			break;}	
		case '5' :{	box[x+1][y-1]++;
			x=x+1;
			y=y-1; break; }		
		case '6' :{	box[x][y-1]++;
			
			y=y-1; break; }				
		case '7' :{	box[x-1][y-1]++;
			x=x-1;
			y=y-1;
			break;	}				
		case '8' :{	box[x-1][y]++;
			x=x-1;
			break; }
		}		
	}
	
	for(int k=0;k<15;k++)
	{
		for(int l=0;l<15;l++)
		{
			cout << box[k][l] << " ";
			
		}
		cout << endl;
	}
	return 0; 
} 
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:27:59
Processing time 0.0204 sec