C/C++ :: Right Hand Maze Not Working Properly
Nov 1, 2014
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:
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
[Code].....
View 6 Replies
ADVERTISEMENT
Oct 19, 2013
I want to alter a string inside a function, but it is not working.Here is the function:
Code:
#include <stdio.h>
void test (char *ch){
ch[0] = 0;
ch[1] = 1;
ch[2] = '';
}
[code]...
View 2 Replies
View Related
Jul 3, 2013
I have a slider control on a dialog box. I am playing a video file and slider moves according to the video elapsed. Suppose I have set the slider range to 100. Now till some point say 90, the slider moves to the point wherever I click the mouse. but at the last point in between some range say 90 - 100 (to the end of the slider), if I click the mouse button anywhere, slider jumps to the end.
I am using a TimeLine control where user can add more than 1 video (1, 2, 4, 8, 10 , 50 etc......), If I use only one video, slider moves as per the video progression.....Issue arises when I add more than 1 video and click on the start button, slider starts moving....Now when I drag the slider to any position or I click the mouse button anywhere on the slider control, slider thumb moves to that position and immediately jumps back to some other position. This is the Issue, I am facing.
share some sample code where slider is moving with the video showing the progress of the video.
I want to implement a functionality similar to VLC player. Wherever user clicks the mouse, slider moves to that point.
View 13 Replies
View Related
May 9, 2013
I tested my count funtion. So my count function is not working properly, it should return 5 because 5 words have prefix "tal," but it is giving me 10. It's counting blank nodes.
This is my main.cpp file
int main() {
string word;
cout<<"Enter a word"<<endl;
cin >> word;
string filename;
[Code] .....
View 9 Replies
View Related
Feb 11, 2015
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
class Player {
private:
char name[20];
int score;
[Code] .....
View 5 Replies
View Related
Jun 5, 2014
Write a program that scores a blackjack hand. In blackjack, a player receives from two to five cards. The cards 2 through 10 are scored as 2 through 10 points each. The face cards - jack, queen, and king are scored as 10 points. The goal is to come as close to a score of 21 as possible without going over 21. Hence, any score over 21 is called "busted". The ace can count as either 1 or 11, whichever is better for the user. For example, and ace and a 10 can be scored as either 11 or 21. Since 21 is a better score, this hand is scored as 21. An ace and two 8s can be scored as either 17 or 27. Since 27 is a "busted" score, this hand is scored as 17.
The user is asked how many cards she or he has, and the user responds with one of the integers 2,3,4, or 5. The user is then asked for the card values. Card values are 2 through 10, jack, queen, king, and ace. A good way to hande input is to use the type char so that the card input 2, for example, is read as the character '2', rather than as the number 2. Input the values 2 through 9 as the characters '2' through '9'. Input the values 10, jack, queen, king, and ace as the characters 't', 'j', 'q', 'k', and 'a'. (Of course, the user does not type in the single quotes.) Be sure to allow upper - as well as lowercase letters as input.
After reading in the values, the program should convert them from character values to numeric card scores, taking special care for aces. The output is either a number between 2 and 21 (inclusive) or the word Busted. Use fucntions, multiway branches, switch statements or nested if-else statements. Your program should include a loop that lets the user repeat the calculation until they are done doing so.
The code runs properly for the first card but then it asks if the user wishes to repest the program. I need to claculate the value of all cards before it asks for that. Here is my code:
#include <iostream>
using namespace std;
int main()
{
[Code].....
View 5 Replies
View Related
May 19, 2013
How do you add a value to the beginning of a string instead of the end?
This is for an assignment and I have to convert the user input (always assuming its a valid decimal number) to binary and store it in a string. I've got up to dividing by two to get the remainder ...
View 19 Replies
View Related
Nov 8, 2014
I almost finished a program but am stuck on sorting the hand im dealing with qsort. sorting by the face values and if they have the same faces im suppose to follow this suit order to determine which one is greater (Clubs, Diamond, Hearts, and Spades) how would i adjust my comparator function to do this for me ?
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define DECK_SIZE 52
struct card {
const char *face;
const char *suit;
[code]....
View 4 Replies
View Related
Dec 3, 2014
I get Error this error. Did I miss something or is that some kind of bug?
Code:
error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'const std::string' (or there is no acceptable conversion)301
Code:
2IntelliSense: no operator "<<" matches these operands
operand types are: std::ostream << const std::string307
Code:
#include <iostream>
#include <fstream>
using namespace std;
const string Alphabet1 = "abcdefgijklmnopqrstuvwxyz";
[Code] .....
View 3 Replies
View Related
May 17, 2014
while (getline(inStream, line))
{
while (inStream >> Student.getId() >> Student.FNAME >> Student.MINIT >> Student.LNAME >> Student.GENDER >> Student.UNITS >> Student.getGpa())
{
while (Student.getId() != id)
{
outStream << line << endl;
}
}
}
This is what I have right now. It shouldn't be a problem, but for some reason I am getting an error trying to >> Student.getGpa()
Error1error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'double' (or there is no acceptable conversion)c:location1301Project 5
I will post more code if needed, but... I just don't know. I have a TON of code so I would rather not if I don't have to.
View 2 Replies
View Related
Jan 24, 2014
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
void Player::player_move() {
Stack stack;
Maze maze;
Lock taken;
// Monster monster;
stack.push_values();
[Code] ....
It should be displaying, because after debugging I discovered the problem isn't with the display_maze function.
View 1 Replies
View Related
Mar 15, 2014
I'm working on a homework problem where we are given a class of functions to traverse a maze and must use those functions to recursively find the end.
The problem I'm having is when the function backtracks it doesn't reset the whole path it came from.
Here is my function that I have created
void solveMaze(Maze M, int path[][MAX])
{
// << overwritten to print the maze out
cout<<M;
[Code].....
View 7 Replies
View Related
Apr 29, 2013
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)
[Code] ....
View 1 Replies
View Related
Apr 1, 2013
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.
View 8 Replies
View Related
Mar 4, 2015
This program is to solve a word maze and find the number of words in the maze from a dictionary file.
The program runs, but stops by finding 1,2 and 3 letter words.
#include<iostream>
#include<vector>
#include<fstream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
vector <string> dict,forward,reverse;
[Code] .....
I also tried to find words using the entire vector as a container, the synopsis code that also did not work is below
while(j<dict.size()) {
if(dict[j].size()>2) {
if (std::find(forward.begin(), forward.end(), dict[j]) != forward.end()) {
cout<<"found word "<<dict[j]<<endl;
[Code] ....
Attached File(s)
dumpling2.txt (2.54K)
Dictionary.txt (718.34K)
View 13 Replies
View Related
Mar 26, 2014
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.
View 6 Replies
View Related
Jun 1, 2013
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...
View 3 Replies
View Related
Oct 1, 2014
I have tried rand() for x and y positions of ghost but does not work. it moves but not randomly it follows same path every time I run the code.
View 2 Replies
View Related
Nov 29, 2014
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){
[code]....
View 5 Replies
View Related
Apr 30, 2014
I have to make a maze with arrays, but i cant seem to move down or up or at all. Here is what I have so far
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
[Code].....
View 5 Replies
View Related
Mar 7, 2013
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;
[Code] .....
View 3 Replies
View Related
Aug 26, 2014
I am unable to get the string seaching function to work. it always says "Nothing found" I am stumped.
Code:
#include <stdio.h>
#include <string.h>
char tracks[][80] = {
"I left my Heart at Harvard Medical School",
"Newark, Newark, You suck balls",
"Dancing with a dork",
"From Here to maternity",
"The Girl from Iwo Jima",
[Code]....
View 3 Replies
View Related
Mar 5, 2013
1. In main() in the while loop entering 'q' does not exit.
2. in the isbnValidation function. The size check for minimum length words will work, but the check for "Invalid ISBN character" doesn't.
3. Every ISBN entered returns as valid. The formula is supposed to multiply the first digit by 10, next by 9 etc (skipping all the dashes) and add up to a weighted total which if valid will divide evenly by 11.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ISBNMIN 10
#define ISBNMAX 14
[Code].....
View 4 Replies
View Related
Mar 30, 2013
I have a file which I am unable to read properly. This is binary file so my code is"
#include<iostream>
#include<fstream>
#include<string>
[Code]....
the file to read can be download from this link :
[URL]
The first content of file should be 1 I am missing few content from the begining
View 2 Replies
View Related
Oct 31, 2013
so i have a container called Source that is of type std::map<std::string, std::vector<std::string>> but when I try to print it with this function:
void Lexer::PrintSource()
{
for(auto Iterator = this->Source.begin(); Iterator != this->Source.end(); Iterator++)
for(auto SubIterator = Iterator->begin(); SubIterator != Iterator->end(); SubIterator++)
cout<< *SubIterator << endl;
}
i get these errors:
Lexer.cpp: In member function 'void Lexer::PrintSource()':
Lexer.cpp:29:42: error: 'struct std::pair<const std::basic_string<char>, std::vector<std::basic_string<char> > >' has no member named 'begin'
for(auto SubIterator = Iterator->begin(); SubIterator != Iterator->end(); SubIterator++)
^
Lexer.cpp:29:76: error: 'struct std::pair<const std::basic_string<char>, std::vector<std::basic_string<char> > >' has no member named 'end'
for(auto SubIterator = Iterator->begin(); SubIterator != Iterator->end(); SubIterator++)
^
View 6 Replies
View Related
Sep 29, 2014
#include <iostream>
using namespace std;
int main()
{
[Code]...
For some reason, I get the cout of
321
1
Because of the a++, shouldn't it be
321
2
The second example is what the cout needs to be.
View 1 Replies
View Related