Area of the room. Your task is to write a program that will find the area of room in a given square maze.
Note. Use recursion for solving this problem.
Input:
First line contains only one number N (3 <= N <= 10).The number that describes the size of the square maze.
On the next N lines maze itself is inputed ('.' - empty cell,'*' - wall).
And the last line contains two numbers - the row and column of the cell in the room those area you need to find.It is guaranteed that given cell is empty and that the maze is surrounded by walls on all sides.
Output:
Output only one number - total amount of empty cells in the selected room.
B. Circle in a Square Write a C++ program that will ask the user to enter the area of a square. Then the program will display the biggest area of a circle that will fit in a given square. Using math.h library is not allowed.
I am writing a program to find the square root of a number. I am using the Newton-Raphson method..Just to clarify a bit of the code.. fabs(1/(x+1)) < 0.001 is to check for relative error..
EXAMPLE: for user entry of 100 if the iteration process ends in 10.055 the answer will return as 10 which is correct. But it isn't doing that.
It compiles I then proceed to run it..prompts me "Enter a number to find the square root of: I type 100 then hit enter...
"The square root of 100 is -1077834936"
My first time writing a program from complete scratch.
And I know there is a sqrt() function...just wanted to write my own.
Code:
#include <stdio.h> #include <math.h> double mysqrt(double a); int main() { double a, result; printf("Enter a number to find the square root of: ");
Add a square root function to the rational class. Have your program print the square root of any rational number. I want to find the square root for numerator and denominator separatetly. divide the answer to get decimals and convert the decimal to fractions. i got till geting the decimal but i want to convert it back to a simplified fraction
// finding greatest common factor int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); }
What I have to write in "int main" to get 1.room list 2.every room temperature, humidity and heat index 3.and how to increase or decrease every parameter
I am able to display a filled and hollow square by themselves, but I can't seem to be able to get them side by side.
So this is my code so far:
[/ #include <iostream> using namespace std; int main()
[Code]....
I can get the hollow square to show up, but the first square just shows up as a single line instead of a square. It seems that it ignores the first if statement in the second loop. I've tried not using an if statement in the second loop but it didn't seem to work either.
I'm attempting to make a room file writer for text adventuring. I compartmentalized each variable for the stream, and dealth with the buffer over runs and all that. Now what I would like to do is make the "get_shdesc" function cut it's lines off at the last white space before it hits the 80th character and continue on the next line. I have no errors, and it functions properly so far.
1. Am I attacking this program in the proper manner so far?
2. If not, what should I be doing?
3. If so, what specifically should I read and study on to get the word wrap effect I am looking for.
So I have a program where I solve a maze using stacks. So my display_maze function take two parameters and displays the maze according to where the x coordinate and y coordinate are.
I have an error during my move function, as my maze doesn't display for some reason
I am creating a right hand maze solution, and it actually works for the most part, but it gets stuck at the sixth spot and will not proceed any further. I cannot seem to find my error even though I know it's probably a small one in my code, here is what I have at the moment:
What c++ code can be used to make an 'X' move through a maze. I have some code, but I'm not sure where to go from there. I have divided the program into three files, A header file, a main file and a .cpp implementation file.
In my implementation file I have:
#include "Maze.h" Maze::Maze() { } void Maze::mazeTraversal(char maze[][COLS], int row, int col, int direction) { enum Direction {DOWN, RIGHT, UP, LEFT}; switch(option)
I'm working on a maze solving program. So far I got the program to solve a maze using the recursive backtracking algorithm. I represent the maze as vector<vector<Square>> where Square is an enum that contains the kind of square (empty, wall, etc.). I use a class Point that contains 2 ints which are used for subscripting the vector of vectors. I have a Point begin and Point end. Now I want the program to solve the maze using the shortest path. I can either use the A* algorithm, Dijkstra's algorithm, or the breadth first search algorithm.
My maze algorithm must be able to count total steps. He is not allowed to "jump" from a deadend back to the cross-way he originally came from.
Code: int R2D2Turbo::findIt(Labyrinth* incLab, int x, int y){ if ((x == incLab->getExit().x) && (y == incLab->getExit().y)) { return 1;
[Code] .....
Due to the nature of recursive algoirthms, he jumps instead of moving the way back from the deadend one by one... The only solutions I could think of are way overloaded...
I'm trying to read a "pointer-based" maze .txt. The first letter in each row corresponds to the room letter...then the letters that follow are North node, East node, South node, and West node respectively. The asterisk indicates an empty room or not a valid option.
Here is what I have come up with, what is happening is after the file is parsed by read_maze it is calling my is_empty function indicating that there is no maze because it doesn't go into the else statement here.
I've attached a sample input file:
maze.txt (130bytes) Number of downloads: 19
We can't assume the rooms will be in order alphabetically A - Z, We are expecting a maximum of 12 rooms and there is a space between each letter or asterisk.
void Maze::read_maze(string FileName){
string line; ifstream inStream; inStream.open(FileName.c_str()); int test = inStream.peek(); int i = 0; if (!(inStream.fail())){ while (!inStream.eof() && test != EOF){
I am trying to get this code eventually to read in a maze file to move the smiley face around in. But right now my current snag is the yes or no to enter the for loop.
#include <iostream> #include <windows.h> #include <conio.h> #include <time.h> using namespace std; int main() { int name; char ans;
I was given an assignment for class to calculate the area of a circle using only the radius as a user input and not using Pi in the code. I need to do this by calculating the areas of a series of rectangles under the curve and adding them together. Using nested loops to continuously reduce the size of these rectangles until the approximated area value is within a margin of error less than 0.1%.
Code: #include<iostream> #include<cmath> using namespace std; int main ()