#include "/>
project 3 solution

project 3 solution - #include "grid.h" #include ...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#include "grid.h" #include <string> #include <cctype> using namespace std; bool getDeltas(char dir, int& dr, int& dc); //************************************* // isPathWellFormed //************************************* bool isPathWellFormed(string path) { // Each iteration of the loop will check one path segment size_t k = 0; while (k != path.size()) { // Path segment must start with a valid direction char dir = tolower(path[k]); if (dir != 'n' && dir != 'e' && dir != 'w' && dir != 's') return false; // Next must come a digit k++; if (k == path.size() || !isdigit(path[k])) return false; // Optionally, there may be another digit k++; if (k == path.size()) return true; if (isdigit(path[k])) k++; } // We get here if we got through the path without a problem return true; } //************************************* // followSegment //************************************* int followSegment(int r, int c, char dir, int maxSteps)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
{ // Make sure (r,c) is a valid empty grid cell int nr = getRows();
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/16/2010 for the course CS 31 taught by Professor Melkanoff during the Fall '00 term at UCLA.

Page1 / 4

project 3 solution - #include "grid.h" #include ...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online