C/C++ :: Moving N Disks - How To Get Number To Reset To Zero
Apr 6, 2014
I need the number of moves to reset to zero every time because right now when when i enter the next number of disks the moves from before are added to the new set of moves. Here is my output
how many disk are you going to start with? 2
It will take 3 moves
how many disk are you going to start with? 2
It will take 6 moves
how many disk are you going to start with? 2
It will take 9 moves
how many disk are you going to start with? 2
It will take 12 moves
how many disk are you going to start with?
the number of moves for 2 disks should be 3 but as u can see every time i enter 2 disks it just adds to the last number of moves how can i fix this ?
//Purpose: Recursively solve the tower of hanoi problem, moving n disks from A to C.
#include<iostream>
#include<conio.h>
using namespace std;
double number;
void move(int,char,char,char);
//function prototype
[Code] ....
View 2 Replies
ADVERTISEMENT
Jun 13, 2014
i want to make moving button or moving box clickable as i am making a game in which i move picture boxes and user clicks on it and his scores increases. but i was unable to do so , so i tried the same concept with buttons but no results.
View 7 Replies
View Related
Apr 17, 2014
How to reset/clear dictionary?
I've already tried:
someList.Clear()
and
var keysToRemove = new List<string>();
foreach (var e in someList)
{
keysToRemove.Add(e.Key);
}
foreach (var key in keysToRemove)
{
someList.Remove(key);
}
And keep getting the error: An item with the same key has already been added. I'm using VS 2012.
View 3 Replies
View Related
Jul 30, 2014
int counter won't reset to 0 when I click the start over button.
protected void startOverButton_Click(object sender, EventArgs e)
{
gameOverLabel.Visible = false;
[Code]....
View 3 Replies
View Related
Apr 12, 2012
Im trying to make a reaction game. I have a grafic that comes up, and the timer starts and when i hit the grafic the timer stops. But my problem is that the Timer doesn't reset.
View 2 Replies
View Related
Apr 23, 2014
In the traditional for loop, you could make the loop start again by resetting the int value
for (int i = 0; i < 10: ++i){
//Do something
i =0;
}
Then it would start the loop again. However I can not seem to find a way to do this with the range based for loop. Is there anyway to force a range based for loop to start from, i = 0 ?
for(const auto &i : vec){
//Do something
//Restart for loop
}
View 9 Replies
View Related
Apr 7, 2015
I've been taking a C++ class, and for a project we need to do, we have to create a simple quiz show game while putting the high scores and names inside a .txt file. We have lessons we can look at to complete it while learning. But at the end there's always a challenge that we should complete to show that we've actually learned the information. For the challenge, we needed to take the information in the .txt file and reset it to its original information. So say there's 5 people preset that have high scores, then a person plays the game and the program asks if they'd like to reset the list. If the user inputted 'y' or any key that needed to be pressed, the program would reset the .txt to its original information.
This is the code that creates the program.
// Include Libraries
#include <iostream>
#include <string>
#include <fstream>
// Include standard namespace
using namespace std;
// Declare Global Variables
int Guess;
int Winnings;
[Code] ....
It works how I need it to and there aren't any problems, necessarily, but I want to know if there's any, more efficient, ways of completing this task. Like if there's any already made function of resetting a file.
This is the code that resets the file. As you can see, it just uses the information earlier in the code inside the if statement. Is there any pre-made function or method of resetting a file?
cout << "Would you like to reset the high scores list? (y or n): ";
cin >> ask;
if (ask == 'y')
{
High_Score[0] = 25000;
High_Score[1] = 12000;
High_Score[2] = 7500;
High_Score[3] = 4000;
High_Score[4] = 2000;
[Code] .....
View 1 Replies
View Related
Feb 18, 2015
I have a character at a co-ordinate, say (3,4) for example, and I need to get him to (10,15). I would like him to move one block every tick or half a second, so that you can see him moving towards his destination. How to achieve this?
View 3 Replies
View Related
Apr 15, 2014
I'm making this program to mess with people and make them think its a virus.
#define _WIN32_WINNT 0x0500 //For hiding your console
#include <cstdlib>
#include <iostream>
#include <Windows.h>
#include <WinBase.h>
[Code]....
At line 42 and 43 I want to make the cursor move around in a circle over and over again but I'm not sure how.
View 4 Replies
View Related
Nov 30, 2014
I want to make an object in array[][] move
Ex:
array[2][5]
array[0][0] = 'O'
O| | | | |
| | | | |
| | | | |
then
|O| | | |
| | | | |
| | | | |
then
| |O| | |
| | | | |
| | | | |
......
how can i print my array in console then change&print it again, then change&print it again,... So it look like O is moving
???
View 1 Replies
View Related
Apr 28, 2013
I have a board where a character is. I need to ask the user whether they want to move it up, down, left right. They are allowed to enter 3 move per turn. like up, up, left. How do I do this?
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
const int COL = 17;
const int ROW = 17;
[Code] .....
View 3 Replies
View Related
Mar 19, 2014
Basically, my function receives an array. For example:
u8 array = {1, 2, 3, 4, 5}
I don't need the first 2 elements, how can I access the array's 3rd element as head? I plan to throw the received array to another function.
array = array[2];
somefunc(array);
Will somefunc get index 2 as start of the array?
View 1 Replies
View Related
Dec 20, 2013
im trying to get my array to display 5,1,2,3,4 from the original 1,2,3,4,5.
void values::movevalues()
{
cout << "postcondition
";
[Code]....
something in this part is making it go wrong, it displayes the original array fine but when it tries to shift it it goes haywire. EDIT: also how would i add elements onto the array?
View 10 Replies
View Related
Nov 1, 2013
I'm trying to serialize and deserialize objects, some static (that works) one moving (doesn't work). In the code you can see that the following int-variables discribe the moving circle:
object->phaseFarbe=phase1;
object->phaseKoord=phase;
object->rot=a;
[Code].....
View 1 Replies
View Related
Jan 6, 2015
I am making a game and I am attempting to get the zombies to move randomly but for the life of me, I simply don't have the knowledge with srand to do it
#include <iostream>
#include <windows.h>
#include <time.h>
[Code].....
View 13 Replies
View Related
Jan 12, 2015
The question says:
Place an Image on top of a Button. Move both when the Button is pushed.
It's here [URL] exercise no.3
look at this code:
#include <GUI.h>
using namespace Graph_lib;
//------------------------------------------------
class rotation : public Window {
public:
rotation(Point xy, int w, int h, const string& title):
[code]....
The problem is that, it is not possible to define an Image in public/private part of the class rotation. Image needs all arguments to be supplied even when declaring one. (Image is here [URL] And if I define that Image in the body of main() function, so how to provide access for void rotate() to change its position with the position of button simultaneously.
View 8 Replies
View Related
Feb 9, 2013
I am not so experianced with c++ myself, but I need to evaluate if a certain idea might work.
I am working with a system for automation purposes that is running on a realtime OS in parallel to windows. Windows and the RTOS exchange data via shared memory. The application in the RTOS is compiled in C++. Now I would like to be able to influence the some data manipulation tasks in the RTOS application without changing the code of the RTOS application. So a concept like calling a dll.
My idea was to create a class with virtual methods in the RTOS application. The objects that are used should then be created on the Windows side with the same class prototype, but specific implementation of the virtual methods. The objects should then be moved to the shared memory, where they are used by the RTOS application.
Is something like this possible or am I completly on the wrong path?
View 4 Replies
View Related
Feb 16, 2015
Im using SDL2 but I'm encountering an unexpected error. I have implemented the same method to move as in my old Projects, but the Player appears to be stuck...
The Player is stuck for maybe half a second, and then everything works as it should, but every time I Change direction or i start moving the Player is stuck for a short Moment.
#ifndef _PLAYER_HPP_
#define _PLAYER_HPP_
#include <iostream>
#include <string>
#include "SDLGameObject.hpp"
class CPlayer : public CSDLGameObject
[code]....
View 9 Replies
View Related
May 21, 2013
This is for a class project. I am having trouble "pulling out" the last element in my array, shifting all the elements back then inserting that last value in the front. Then also displaying the array after the shift. here's my code.
#include "stdafx.h"
#include<iostream>
using namespace std;
[Code].....
View 3 Replies
View Related
Oct 21, 2014
I'm working on designing a game in C++ that is similar to the "find the ball under the cup" game. I have a Sonic the Hedgehog icon (weird I know, but it was the first thing that came to mind) that will be hidden underneath one of three rectangular blocks.
Here is how I envision this working:
On the main menu I have 3 buttons which represent 3 different difficulty levels
Easy- blocks move 3 times at a slow speed
Medium- blocks move 5 times at a slightly faster speed
Hard- blocks move 10 times at a fast speed
When the user clicks one of these buttons they will be taken to the game screen.
Sonic will be displayed for 3 seconds and the user will then see him be covered with one of the three blocks.
The three blocks will then move in a random pattern along the middle of the screen at the speed and number of times associated with the button that was pressed.
Once the blocks stop moving, the user is to click on the one they think Sonic is underneath.
If they choose correctly, they'll be taken to a "Winning Screen" that displays a congratulatory message and 2 buttons. Play Again- returns the user to the main menu and the game starts over with a new random pattern. Quit- the window closes.
If they choose incorrectly, they'll be taken to a "Losing Screen" that displays a "Try Again" message and 2 buttons that have the same function as the buttons on the winning screen.
I have never worked with any kind of graphics before other than in HTML and Javascript. I have managed to create the main menu, but how to do the actual game portion of the project. I've been trying to take it a step at a time, (for example, I first figured out how to set the background color for the console window, after I got that right I figured out how to add buttons) but the rest of this seems to depend on each other.
Here is what I have so far:
Main menu:
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
using namespace std;
class MainMenu
[Code]....
So I've got the screens pretty much designed now (with the exception of the game screen itself) but how to tie everything together.
In case my description wasn't too clear, here is a game that I found on Google that is pretty much exactly what I'm looking for. [URL]
View 2 Replies
View Related
Mar 21, 2013
I'm working on a personal project with a screen that looks like this:
+++++
+++++
++O++
+++++
+++++
And below that it asks where you want to move. I've done the majority of the work, I just have to figure out how to actually move the O. Here's my source code:
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
[Code]....
View 2 Replies
View Related
Jul 5, 2014
I know there is strtok() to do the tokenization;but all strtok() examples I have seen only output one token at a time, moving the pointer ahead. Can't the tokens be saved somewhere?
View 6 Replies
View Related
Nov 22, 2012
I have to write tic-tac-toe game in Visual 2010. My only problem is that I don't know how I can move the cursor with arrows in the console in order to fill in chosen positions in 3x3 table:
Code:
_ _ _
_ _ _
_ _ _
I guess that the needed functions are in here: [URL] ....
but I don't know from what to start with...
View 1 Replies
View Related
Oct 29, 2014
lets start with the code:
while(run)
{
if (PeekMessage(&msg, win->win_handle,0,0,PM_REMOVE))
{
[Code]......
I have created a basic window and i discovered that while resizing or moving my windows, the myframe() don't get any calls at all.
Is there anyway possible that myframe gets at least someof the calls while those things are happening
View 1 Replies
View Related
Sep 16, 2014
Currently I'm trying to do something extremely basic: delete or move a file
I have a mapped network drive (Y) where I have a file I need to move from one folder to another
First was doing the obvious:
System.IO.File.Move("Y:TempFile.txt", "Y:Temp2File.txt");
Not much to go wrong here, right? As long as I have the correct permission to write in the folders and the folders exists, this would normally go smooth. But for some reason it only copies the file. The source file still exists, but it has successfully copied the file to the destination folder. No exceptions has been thrown or anything... but the file still exists in the source directory
I then changed the code to the following:
System.IO.File.Copy("Y:TempFile.txt", "Y:Temp2File.txt");
System.IO.File.Delete("Y:TempFile.txt");
Console.WriteLine("See mommy, no Exceptions");
As expected the file copies correctly, but the delete command is completely ignored. The file is not deleted, but the Console.WriteLine command is called
I'm running the application as the logged in user. The user has permission to delete the file. If I try from Windows Explorer, the file is correctly deleted. Unfortunately my application refuses to delete the file and even worse, it will not even throw an Exception.
View 10 Replies
View Related
Apr 22, 2013
I am currently starting to attempt to make a program that can move my cursor to certain colors on my monitor. The problem is this seems like it will be 10x harder than I first thought.
View 4 Replies
View Related