Ejemplo n.º 1
0
static void solveMaze(void)
{
    int x, y, offset;


    for (y = 0; y < height; y ++)
	for (x = 0; x < width; x ++)
	    maze[y][x].visited = false;

    y = 0;
    x = 0;

    while (y != height - 1 || x != width - 1) {
	draw(x, y, true);
	maze[y][x].visited = true;

	if (!maze[y][x].right && !maze[y][x + 1].visited) {
	    dp.addLast(offset(x + 1, y));
	    maze[y][x + 1].from = 1;
	}

	if (!maze[y][x].bottom && !maze[y + 1][x].visited) {
	    dp.addLast(offset(x, y + 1));
	    maze[y + 1][x].from = width;
	}

	if (x > 0 && !maze[y][x - 1].right && !maze[y][x - 1].visited) {
	    dp.addLast(offset(x - 1, y));
	    maze[y][x - 1].from = -1;
	}

	if (y > 0 && !maze[y - 1][x].bottom && !maze[y - 1][x].visited) {
	    dp.addLast(offset(x, y - 1));
	    maze[y - 1][x].from = -width;
	}

	if (dp.getLast() == offset(x, y)) {
	    draw(x, y, false);
	    dp.removeLast();
	}

	offset = dp.getLast();
	x = xcoord(offset);
	y = ycoord(offset);
    }

    draw(width - 1, height - 1, true);
}
Ejemplo n.º 2
0
int main(int argc, char** argv)
{
    Deque<char> a;
    char base_pair;
    while(cin >> base_pair)
        a.addLast(base_pair);
    while(!a.isEmpty()) {
        if(a.size() == 1) {
            cout << "false" << endl;
            return 0;
        }
        char first = a.removeFirst();
        char last = a.removeLast();
        switch(first) {
        case 'A':
            if(last != 'T')
            {
                cout << "false" << endl;
                return 0;
            }
            continue;
        case 'T':
            if(last != 'A')
            {
                cout << "false" << endl;
                return 0;
            }
            continue;
        case 'C':
            if(last != 'G')
            {
                cout << "false" << endl;
                return 0;
            }
            continue;
        case 'G':
            if(last != 'C')
            {
                cout << "false" << endl;
                return 0;
            }
            continue;
        default:
            cout << "false" << endl;
            return 0;
        }
    }
    cout << "true" << endl;
    return 0;
}
Ejemplo n.º 3
0
Deque<Point2D> PointSET::range(const RectHV& rect) {
	Deque<Point2D> points;
	for (Point2D p : set_)
		if (rect.contains(p)) points.addLast(p);
	return points;
}