|
int findShortestPath(int row, int col, int path,
int minpath) { if (out of bounds, hit a wall, or path is longer than the shortest one found so far) return minimum path length; if (reached the end of maze) compare path length and min path length, return one whichever's smaller; mark path as visited by i.e. assigning a number to it, like path length so far; findShortestPath(row,col+1,path+1,minpath);//go right; findShortestPath(row+1,col,path+1,minpath);//go down; findShortestPath(row,col-1,path+1,minpath);//go left; findShortestPath(row-1,col,path+1,minpath);//go up; return minpath; } |
There are a few ways to solve this problem. The notable ones are:
| #include <iomanip> using namespace std; cout<<fixed<<setprecision(2)<<answer<<endl; |
| #include <cmath> double round(double x) { return floor(100*x+0.5)/100; } |
|
char chr='B'; chr+=32; cout<<chr;//'b' |