C++ :: Back Tracking And Goto Functions
Apr 27, 2012
I have a project where I have to schedule 3 doctors for 28 days. Doc A, B, and C. The rules are:
1. They can't work back to back, but only on weekends. Example Doc. A can't work Monday and Tuesday, If Doc. A works Saturday, he must work Sunday also.
2. Doc. A and B work alternate weekends.
3. Doc. C can't work Tuesday or weekends.
I'm trying to base my project off of the 8 Queens program that uses backtracking and the goto function. Right now, I'm just trying to get my program to print this
100100100
010010010
001001001
Here is my goto Code
#include "stdafx.h"
#include <iostream>
#include<iostream>
using namespace std;
void print();
#define n 28 //28 day schedule
int a[n]={};
[Code] ....
If you look at my code you will notice that it prints out like this, where array c doesn't take in account for array a.
1010101010101
0101010101010
1010101010101
I need getting the program to modify a[], b[], and c[] when necessary. I should be able to change any array element to '1' and it will automatically fill in the schedule by itself. example
010001000101001
100100101010010
001010010000100
View 13 Replies
ADVERTISEMENT
Feb 23, 2015
Is there any way to track what functions from what class are called at runtime? What I mean is a list of functions or classes which have been called at runtime.
View 1 Replies
View Related
Dec 17, 2014
I've been making an RPG in C++ and I've used goto all throughout the program. After receiving an error and Googling how to fix it, I read that you shouldn't use goto. What can I use as a instead of goto, which isn't 'considered bad programming practice'?
View 9 Replies
View Related
Nov 21, 2013
My program has a goto label in it and when the program is not instructed to goto the label, it does. When control goes to the line that it is on, even if no where does it say to execute the label's content, it does execute it.
View 6 Replies
View Related
Feb 26, 2015
Project Golfer.cpp
So when you enter the number 99 its supposed to quit the program and it wasnt so i fixed that then i noticed that if you don't hit the green its supposed to loop back to a certain point but it was going to far back so i put a goto statement in and now it wont output my data table.
View 1 Replies
View Related
Feb 28, 2013
You are tracking the prices of some asset over time. The user will input a series of floating-point prices (e.g. 16.105 for sixteen dollars, ten and a half cents). When the user enters the price 0 (zero), output the overall minimum, mean, and maximum prices. Hint: there could be thousands or millions of prices to process, so do not try to store each one as it arrives, but keep a running total..
I've been using a while loop for user input, but I don't know how to get the last 0 that marks the end of the list to not be included in calculating the average.
View 4 Replies
View Related
Oct 10, 2013
I have been learning c++ for about 1 month. So my problem is that suppose i have array[6]={10,-1,3,54,2,12}
I want to fill new array with {1,4,2,0,5,3}
because -1 is the lowest and its index is 1
2 is the lowest and its index is 4
3 is the lowest and its index is 2
10 is the lowest and its index is 0
12is the lowest and its index is 5
54 is the lowest and its index is 3
I want to sort from lowest to highest but using the index value. Here is what i have but the output i get is {1,4,2,4,5,5}
1,4,2 is right but then its wrong.
#include <iostream>
using namespace std;
void swap(int& v1, int& v2);
int main() {
const int size = 6;
int arry[6]={10,-1,3,54,2,12};
int sortedArry[6];
[Code] ....
View 1 Replies
View Related
Apr 19, 2013
How to detect when mouse pointer entering on toolbar .
View 2 Replies
View Related
Mar 20, 2014
I'm a little confused by my programming assignment this week. I've been working at it Wednesday and I've made progress but I'm still confused as to how I'm supposed to do this. The class I made is called Stack, and it's derived from a template class called StackADT. We also utilize a class called unorderedLinkedList, which is derived from a class called linkedList.
We're supposed to implement all of the virtual functions from stackADT in the Stack class. The Stack data is stored in a an unorderedLinkedList, so what I'm confused by is how to implement a few of the Stack functions because there are no functions in unorderedLinkedList which we could call to manipulate the data.
As you can see from my attached code, I'm really confused by how I'm supposed to implement the pop() and top() functions, and I also think my initializeList() function is wrong. We don't have any similar functions in unorderedLinkedList to call, so I'm at a loss of how i'd access my unorderedLinkedList. My initial thought was to call the similar functions in the class that unorderedLinkedList was derived from, linkedList, but I'm unsure of this is what we're supposed to do, or if theres actually a way to access my unorderedLinkedList without having to use the functions from the base class.
NOTE: We're not allowed to modify stackADT, unorderedLinkedList, and linkedList.
Stack.h
#include "stackADT.h"
#include "unorderedLinkedList.h"
template<class Type>
class Stack: public stackADT<Type>{
template <class T>
struct nodeType
{
T info;
nodeType<T> *link;
[Code]...
View 3 Replies
View Related
May 3, 2013
At the moment im trying out with pointing to an array of functions. I got this working as following:
typedef void (* functionPtr) ();
functionPtr functions[2][2]={{do11,do12}, {do21,do22}};
void do11(){DEBUG_PRINTLN("11");}
void do12(){DEBUG_PRINTLN("12");}
void do21(){DEBUG_PRINTLN("21");}
void do22(){DEBUG_PRINTLN("22");}
void loop(){
A=0;
B=1;
functions[A][b]();
}
But now I'm trying to use this to point to a function inside a class so instead of do11, i want to be able to point to Basic.Do11. Somehow this doesnt work and I keep on getting this message:
error: argument of type 'void (Basic::)()' does not match 'void (*)()'
View 2 Replies
View Related
Mar 7, 2014
Here's a small portion of my program:
Code:
int choice(void) {
char buffer[BUFSIZ];
char answer;
printf("
[Code] .....
I am wondering which is correct to use
Code: return choice();
or
Code: choice();
return num;
View 4 Replies
View Related
Mar 25, 2014
Value x is a 32-bit unsigned integer 3:
00000000000000000000000000000011
If we use bitwise-shift to shift all bits to the right by 2, x is 0:
00000000000000000000000000000000
If we then do a bitwise leftshift on x by 30, do we end up with:
11000000000000000000000000000000
or
00000000000000000000000000000000
In other words, when we perform right shift which clips away the least most significant bits, and then do a left shift, is it possible for those bits to reappear?
View 2 Replies
View Related
Oct 23, 2014
Here is a simplified version of my Menu class, where submenus can be inserted arbitrarily deep. I need to add a new functionality "go back to previous menu", which I would like to be activated by entering 0 (universal command for all Menu instances). I considered the Memento Pattern, but that doesn't seem to quite fit. add that functionality to my Menu class.
#include <iostream>
#include <cstring>
using namespace std;
const int END = -1, NO_SUBMENU = 0;
[code]....
View 3 Replies
View Related
Jul 31, 2013
I am trying to use push back in a 2D vector but I don't know how to. This is what I have:
vector <vector <BigInt> > matr;
for (BigInt i=0;i<rij;i++) {
for (BigInt j=0;j<kolom-1;j++) {
matr.push_back().push_back((i+1)^(pow-j));
}
}
I quickly invented something but that doesn't work obviously. it should be equivalent to this: (the only problem in the code below is that those indexes don't exist yet that's why I need push_back())
for (BigInt i=0;i<rij;i++) {
for (BigInt j=0;j<kolom-1;j++) {
matr[int(i)][int(j)]=(i+1)^(pow-j);
}
}
View 2 Replies
View Related
Apr 9, 2014
I'm new here! I just wanted to ask, how can I go back to Main menu using this code that I have made (I know it's not yet finish I'm using Visual Studio c++ 2010! I there are any errors in my codes
Project: Computer Shop System
#include <iostream>
#include <string>
using namespace std;
int pcnum[5],x; //choice pc
int pc;
int i; //name
int y; //hours
[Code]...
View 1 Replies
View Related
Apr 24, 2014
I'm trying to decompile an old software that I need to start using again.
when I tried to open the file in ILSpy I got this message "This file does not contain a managed assembly"
I tried all other decompilers but still no luck.
View 3 Replies
View Related
May 23, 2013
I have below classes
Code:
class moClassValueContainer {
public:
moClassValueContainer();
moClassValueContainer(string,int);
[Code] ....
In my main.cpp, I have blow loop
Code:
for (xml_node tnode = it->first_child(); tnode ; tnode = tnode.next_sibling()) {
Container tmpContainer(tnode);
if (tmpContainer.getType() == SINGLE) {
string t = tmpContainer.getName();
[Code] ....
I cannot push_back(t). I examined the code with debugger, t has correct string value assigned, but even after 20-30 iterations, there is no element for headerFields vector.
View 1 Replies
View Related
Oct 11, 2014
I am writing another program and I cannot find for the life of me how to loop the program back to the start of a function.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int choice;
char band1, band2, band3, band4;
printf ("This program calculates the resistor value based on the colours of the wire.
(enter the integer near the command)
");
printf ("What would you like to do?
[Code].....
This is my current iteration of the program. Obviously, I haven't finished writing the case 1 of the first switch, but for the other ones. I thought that return main would cause the program to loop back to the beginning after executing the case, but I see that it is not the case (pun not intended). Anyways, what would I have to insert to cause the program to loop again (other than for case 3)? And another question, why is it that in scanf in the first case, the program only accepts two characters before finishing?
View 4 Replies
View Related
Nov 26, 2013
I need to convert from an array to a list and back.
array to list: (x,y) to int and int to (x,y)
I wrote this function:
Code:
/*
* inputs:
* coordX: column;
* coordY: line;
* nc: number of colums
[Code] ....
It works fine but the other way around is giving me sleeping problems. I was thinking something about this:
Code:
/*
* inputs: integer
* returns: X coordinate
*/
int inttoX(int n, int nc){
int coordX;
[Code] .....
I don't need the code, just want to continue... i'm a little blocked.
View 2 Replies
View Related
Jun 18, 2014
I have a device that have some communication protocols and it will respond and send some specific data when somebody communicates with the device. I tried to build a C code that will send those protocols to the device and then store those sending data. Now I don't understand that how to send those commands. Other things than that I can manage with the file handling programming.Is there any predefined function using which it will send some specific data or something like that??
View 1 Replies
View Related
Nov 4, 2013
I am trying to get all these functions work together and send the value of countX and countY back into main from function2() and function3() to be used by function4() later on.. But I keep getting 0 printed out and I am not quite sure why.
Code:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define maxrow 20 //defines maxrow as a constant of 20
#define maxcol 30 //defines maxcol as a constant of 30
}
[code]....
View 2 Replies
View Related
Jun 24, 2014
I've been creating an API and I'm now stuck on callbacks. There are many APIs that allow callbacks to class members(e.g. Windows API) using a void pointer to the object. I've searched the internet for hours and I can't find one example of how to use the "hidden object parameter" of an class method pointer that doesn't use std::function/bind or boost::function/bind. Any information on how API's like Windows API are able to use class methods as callbacks
View 6 Replies
View Related
Apr 16, 2013
I am making a calendar to look similar to Outlook, but it is in c++ and I am starting from scratch. I have broken it into parts, and the part I am struggling with is making the next/previous month button to add to the calendar. I have a basic code, but I don't know exactly what I need to change or add to it. The code is,
#include "std_facilities_lib_3.h"
#include <iostream>
#include <sstream>
#include "Graph.h" // get access to our graphics library facilities
#include "GUI.h"
#include "Window.h"
[Code] .....
View 2 Replies
View Related
Jul 10, 2014
I have made a calendar using a resource file and using the winapi
CALENDAR_DLG DIALOG 0, 0, 186, 95
STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
CAPTION "Calendar"
FONT 8, "Ms Shell Dlg" {
CONTROL "", CALENDAR, "SysMonthCal32", WS_VISIBLE, 0, 0, 186, 95
}
My call back function is
BOOL CALLBACK DlgCalendar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch(uMsg) {
case WM_INITDIALOG: {
} return TRUE;
[Code] .....
DTN_DATETIMECHANGE is not being called ? What is UMSG equal to when a date is changed in the calendar?
View 5 Replies
View Related
Feb 17, 2015
With the LoadLibrary function (followed by GetProcAddress) you can get a function or any other thing that is on DLL export. AFAIK, when you assemble one program, it loses all user-reading data (names in general). How do the OS's get them?
View 3 Replies
View Related
Mar 4, 2014
I was asked by my teacher to create while loop for this, iv have completely for gotten how and all the tutorial that i have found show basic lopping.
#include <iostream>
#include <iomanip>
using namespace std;
void checkAnswers(char[], char[], int, int);
int main(int argc, const char * argv[]) {
int choice = 0;
const int num_question=20;
const int min_correct=15;
char answers[num_question] ={
[Code] ....
View 5 Replies
View Related