[ create a new paste ] login | about

Link: http://codepad.org/sLlWFCXs    [ raw code | output | fork ]

hoaithu.melody - C++, pasted on Mar 9:
//ladder
#include <iostream>
#include <conio.h>

using namespace std;
#define max 100
int main()
{
	int n, i, j;
	int maze[max][max];
	freopen("Testcase.txt", "r", stdin);
	for(int testcase = 1; testcase <= 10; testcase++)
	{
		int col, row;
		cin >> n;
		for(i = 0; i < max; i++)
		{
			for(j = 0; j < max; j++)
			{
				cin >> maze[i][j];
				if(maze[i][j] == 2)
				{
					row = i;
					col = j;
				}
			}
		}

		while(row >= 0)
		{
			if(col > 0 && maze[row][col-1] == 1)
			{
				maze[row][col] = 0;
				col--;
				continue;
			}
			if(col < max - 1 && maze[row][col+1] == 1)
			{
				maze[row][col] = 0;
				col++;
				continue;
			}
			row--;
		}
		cout << "#" << testcase << " " << col << endl;
	}
	getch();
	return 0;
}


Output:
1
2
3
4
Line 18: error: conio.h: No such file or directory
In function 'int main()':
Line 47: error: 'getch' was not declared in this scope
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: