chococrack 74 Junior Poster

Take a look at Game-maker.. It is more geared toward drag and drop and 2d rather than 3d but it can be fun to toy around with:

http://www.yoyogames.com/make

chococrack 74 Junior Poster
[B]if number < smallest

 smallest = number[/B]
chococrack 74 Junior Poster

5 factorial:

5! = 5 x 4 x 3 x 2 x 1 = 120

4! = 4 x 3 x 2 x 1 = 24

15! = 15 x 14 x 13 x 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 1307674368000

To get the other values ( for 0 and then for negative ), first check if the number is greater than 0, if it is, then do the factorial. If it isn't check if it is equal to zero, if so, " The factorial of 0 is 1 " otherwise "Invalid Input"

Good enough?

chococrack 74 Junior Poster

Good deal then :) Hope you figure it out

chococrack 74 Junior Poster

Set your x and ctrl to whatever you input for inpt.

Then you can run through ( ctrl > 0 )

and output x like

[B]while X is larger than zero then
    print X
    subtract one from X
endwhile[/B]

Decrement your ctrl counter and set X equal to ctrl and you're done

chococrack 74 Junior Poster

So eh... when you're calling your deal here

QuickSort(&test);

with your 20 element (size)

and then you're doing this

int Low;  // The left end.
int High; // The right end.
int Pole; // The pivot.
...

int Size=RawData->size(); // Get the size of the vector to be altered.

vector<float> DataRestructure(Size); //A new vector is called up to receive the incoming data off of the pointer
Begin=0;
End=Size-1;
Low=Begin;
High=End;
Pole=(Low+High)/2;

You're setting High to End, which is Size-1, which is 20 - 1

Then you're calling Pole = ( 0 + 19 ) / 2 ... thats 9.5

Then you're checking for DataRestructure[Pole] ... which in this case is DataRestructure[9.5] and theres no such animal

I don't know if thats your problem but thats something that I've noticed

chococrack 74 Junior Poster

You may find " Linking an Executable to a Dll " from MSDN helpful.

Depending on what version of VS you are using (this is for 2008): You can got to Project Settings > Properties > Configuration Properties > Linker > Input

Under Additional Dependencies add "Fmod.lib" to anything that is already there. You can also skip this step by using:

#pragma comment( lib, "Fmod.lib" )

Remember to add the lib and headers to your project and to include the header files when you are using the functionality.

chococrack 74 Junior Poster

This post may or may not be helpful. :)

chococrack 74 Junior Poster

Found a beautifully written post regarding how to do this by Narue:

http://www.daniweb.com/forums/post106219.html#post106219

The suggestion is
clear the input stream of junk and use

cin.get();
chococrack 74 Junior Poster

oh wow yes indeed

might need a prototype

chococrack 74 Junior Poster

Not only that semi-colon but also look at your braces in your function: (I marked things in red)

void final_grade(grades& the_grades)[B];[/B] 

{
cout << "Enter the score of the first quiz: "; 
cin >> the_grades.score_quiz; 
cout << "Enter the score of the second quiz"; 
cin >> the_grades.score_quiz2; 
cout << "Enter the score of the midterm"; 
cin >> the_grades.score_midterm; 
cout << "Enter the score of the final"; 
cin >> the_grades.score_final; 
[B]} [/B]
char letterGrade (double numericGrade) 

[B]{[/B]
char letter; 
if (numericGrade < 60) 
letter = 'F'; 
else if (numericGrade < 70) 
letter = 'D'; 
else if (numericGrade < 80) 
letter = 'C'; 
else if (numericGrade < 90) 
letter = 'B'; 
else 
letter = 'A'; 

return letter; 
}

// The error message I get is 
// expected unqualified-id before '{'token
// expected `,' or `;' before '{' token

Also a void function does not have a return, so you probably want the function prototype to look something like

double myFunction( . . . );
chococrack 74 Junior Poster

Get the coordinates of the cursor relative to the entire screen.

Then use something like GetWindowRect to grab the coordinates of the game window.

Then from there it should be easy to perform a simple conversion to get the mouse coordinates relative to the game window

Reference: http://msdn.microsoft.com/en-us/library/ms633519(VS.85).aspx

chococrack 74 Junior Poster

This isn't a bug in VS if that is the question.

Is there any reason you are insistent on using an unsigned short for your loop control variable? It would be much simpler to just use a plain old int

chococrack 74 Junior Poster

can you post the code you are using to decode the bmp?

chococrack 74 Junior Poster

This is C++'s scope resolution operator. This resets the scope of that variable in this case. You see this all the time when you declare a class and then implement its functions elsewhere.

For example, you have

class myClass {
int myFunction();
};

int myClass::myFunction()
{
 ...
}

The :: is giving access to the function in myClass outside of this scope.

Now for another example, using var

int var = 3;

int main()
{
    float var = 4.5;
    {
          double var = 6.5;
          int myVar = ::var;
    }
}

Here, using the scope resolution operator, myVar is going to be set to 3.

Hope this helps

chococrack 74 Junior Poster

I'll use the one line system("PAUSE") or simple cin.get(); in smaller "amateur" code that I test things on.

For professional projects, I tend to use my IDE of choice's built in debugging tools (like breakpoints in VS).

The function you posted works fine, as does the simple one line I posted.

Flaming another contributors post is definitely not the way to go about gaining a great reputation here.

chococrack 74 Junior Poster

the question was the title so can there be multiple getters to one setter?

Theres absolutely nothing wrong with setting all three in one function and then having independent get functions for each one. Cheers !

chococrack 74 Junior Poster

If you're in windows (like using visual studio 2005) then just use

system("PAUSE");

If you're on a Unix console, you really don't need a pause after you run your code.

The snippet above may be useful for pausing at different times other than after the code runs, to run the program in chunks for example

dmt.Arsenal commented: using system("PAUSE") ?? bad !! +0
chococrack 74 Junior Poster
[B]isPrime = true

num = 2

while num <= 1000
     for i in( 2 to num/2 )
	    if num % i = zero
                isPrime = FALSE
	    endif
     endfor
	
     if isPrime = TRUE
         PRINT num
     endif
	
     increment num
     isPrime = TRUE
endwhile[/B]
chococrack 74 Junior Poster

You're on the right track, but you're not getting the prime number part correct.

Try re-writing the inside of your while loop

and remove the cout << numbers after the loop, as you wouldn't want to print anything there


in other words

#include <iostream>
using namespace std;
 
int main() {
	int number;
	number = 2;

	while (number <= 1000) {

                ...
		IF number IS PRIME THEN
                   PRINT number
                ...

		++number;
	}

	return 0 ;
}
chococrack 74 Junior Poster
chococrack 74 Junior Poster

Forget about it. If you get the looping part then move on. This example is a bit confusing for a beginner to be honest.

chococrack 74 Junior Poster

what are you trying to do with the octals?

chococrack 74 Junior Poster

Ok so lets break it down a little bit:

// the number of blanks surrounding the greeting
	const int pad = 1;

This little number here is the "pad"ding

// the number of rows and columns to write
	const int rows = pad * 2 + 3;
	const string::size_type cols = greeting.size() + pad * 2 + 2;

This is where you're calculating the row and column sizes

The first line --> rows = pad * 2 + 3, comes out to 5 rows.
The second line --> cols = greeting.size() + pad * 2 + 2 takes the size of the name you enter along with the greeting text, and adds to it 2 times the padding value plus 2 more. In my case it uses the size of my name along with the greeting "Hello, " + name + "!" ---> 13 chars plus 2 times the padding + 2 ---> 13 + 4 = 17

chococrack 74 Junior Poster

I read a book a couple of years ago with tons of great tips for creating well structured code called Code Craft: http://nostarch.com/codecraft.htm

It was really a great read and worth a look if you're looking for ideas on what is generally considered "good" programming practices.

chococrack 74 Junior Poster

Here is what it looks like when I run the code:

Please enter your first name:  Blake

*********************
*                   *
*   Hello, Blake!   *
*                   *
*********************

What are you having trouble with?

chococrack 74 Junior Poster
chococrack 74 Junior Poster

Re-post your code (using the CODE tags) and we'll guide you in the right direction :)

chococrack 74 Junior Poster

In your MEDIAN section:

//MEDIAN
if (total % 2 == 0)
{
median = ((students[total/2-1])+(students[total/2])/2.0);
}
else if (total % 2 == 1)
{
median = students[total/2];
}
cout<< "The median is: " << median << endl;

You're using "total" to reference your students[], which is going to give you some ugly results. You want to use stdSurveyed and then use a floor function to get integer values (thats when you'll see errors about "integral type" )

Hope this helps

chococrack 74 Junior Poster

Well here in the MODE:

//MODE
int x;
int freq = 0;

frequency = new int[freq];

for (int count = 0; count < stdSurveyed; count++)
{
x=students[total];
frequency[x]++;
}
cout << "The mode is: " << mode << endl;

You are outputting mode without doing anything to modify it where you are supposedly computing it.

chococrack 74 Junior Poster
// result of the operation when addition is chosen
resultAdd == firstNo + secondNo;
cout<< "the sum of the numbers are ->/n";
cin >> "resultAdd";

Just a couple of little errors here:
1. you used == in place of the assignment operator =
2. the cin >> "resultAdd"; line is not needed

I believe this is what you intended:

// result of the operation when addition is chosen
resultAdd = firstNo + secondNo;
cout<< "the sum of the numbers are ->" << resultAdd << "/n";

Follow this structure and you should be able to fix the other problems

chococrack 74 Junior Poster
//Namespaces needed
using System.Diagnostics;

public bool FindAndKillProcess(string name)
{
	//here we're going to get a list of all running processes on
	//the computer
	foreach (Process clsProcess in Process.GetProcesses()) {
		//now we're going to see if any of the running processes
		//match the currently running processes by using the StartsWith Method,
		//this prevents us from incluing the .EXE for the process we're looking for.
		//. Be sure to not
		//add the .exe to the name you provide, i.e: NOTEPAD,
		//not NOTEPAD.EXE or false is always returned even if
		//notepad is running
		if (clsProcess.ProcessName.StartsWith(name))
		{
			//since we found the proccess we now need to use the
			//Kill Method to kill the process. Remember, if you have
			//the process running more than once, say IE open 4
			//times the loop thr way it is now will close all 4,
			//if you want it to just close the first one it finds
			//then add a return; after the Kill
			clsProcess.Kill();
			//process killed, return true
			return true;
		}
	}
	//process not found, return false
	return false;
}

Taken from: http://www.dreamincode.net/code/snippet1543.htm


==================================================================== (edit)

So eh,

FindAndKillProcess("AcroRd32.exe");

chococrack 74 Junior Poster

Referencing the link: http://www.vbforums.com/showthread.php?t=527469

MatEpp's comment lead me to a working solution.

the actual code which eliminates the sound for me is as follows:

if (e->KeyValue == (char)13)
{ 
    e->SuppressKeyPress = true;  // the magic
    textBox2->Focus();
}

Thanks for the help!

chococrack 74 Junior Poster

It's not so much a beep as it is an event sound. I'm writing this for a person who will be running this on his own machine, so disabling the windows sounds is not an option. It sounds as though it is playing the alert sound (similar to a popup "OK" box Alert). I'm not too sure where to go from here, as the textboxes work as they should but produce a sound I do not want. :/

chococrack 74 Junior Poster

I am having trouble finding out info regarding how to stop my application from "Beeping" every time I change focus with the "ENTER" key.

For the sake of clarity here is the specific action and code which produces a sound (which I want to eliminate):

I am simply trying to change focus from one textBox to the other, when for instance a Last Name is entered, the user presses ENTER and it switches to the next textbox.

private: System::Void textLast_KeyDown(System::Object^  sender, System::Windows::Forms::KeyEventArgs^  e) {
		 
			if (e->KeyValue == (char)13)
			{ 
				textFirst->Focus();
				
			}
}

The code works, but every textbox that I hit "Enter" on, I get an Alert or BEEP that I want to go away.

chococrack 74 Junior Poster

Post your code.

chococrack 74 Junior Poster

Also, whats the value of strlen(customer) at that point? Make sure its not falling off the array (just as an extra thing to look at possibly).

chococrack 74 Junior Poster

Well thats not very nice of it then :<

What class is getData function in and what does it look like?

chococrack 74 Junior Poster

When I want to thoroughly test something I take it one TINY step at a time, but that might have a lot to do with my OCD :D

I would worry about the first step, ensure that works fine, then move on to testing the rest of them, rather than trying to monitor everything all at once.

chococrack 74 Junior Poster

If its just a problem with retreiving the private member, why not just create a public function within that class to grab the private value and return it:

int getPrivateThingy()
{
    return privateThingy;
}
chococrack 74 Junior Poster

Use the Call Stack window to work your way back up the call stack, looking for corrupted data being passed as a parameter to a function. If that fails, try setting a breakpoint at a point before the location where the access violation occurs. Check to see if data is good at that point. If so, try stepping your way toward the location where the access violation occurred. If you can identify a single action, such as a menu command that led to the access violation, you can try another technique: set a breakpoint between the action (in this example, the menu command) and the access violation. You can then look at the state of your program during the moments leading up to the access violation.

You can use a combination of these techniques to work forward and backward until you have isolated the location where the access violation occurred. For more information, see Using the Call Stack Window.

http://msdn.microsoft.com/en-us/library/6decc55h(VS.80).aspx


So meh.. wants us to look at parameters first I take it

chococrack 74 Junior Poster
define total = 0
define array[n] = {n1, n2, n3, n4, ...}
for 0 to n - 1
    total = total + array[n]
print 'Average: '
print total / n
end
chococrack 74 Junior Poster

try returning ' ' instead of " ", don't know why but something tells me it might work

chococrack 74 Junior Poster

alrighty, so with those specific numbers the output looks like this:

How many colors will there be? 3
How many rounds? 5
How many assemblers/painters? 3
Enter start state for game (make sure you put the
colors into the program in the same order everytime.)
Warehouse
3
3
3
Kanban Board
3
3
3
Paint
1
1
1
Paint round 2
1
1
1
Assembly round 2
1
2
0
Enter Assembly numbers for round 3
0
1
2
Enter Assembly numbers for round 4
1
0
2
Enter Assembly numbers for round 5
0
2
1
Enter Assembly numbers for round 6
1
1
1
Warehouse
3,3,4,3,3,
3,2,2,2,0,
3,4,3,1,0,

Kanban Board
134525044,134525076,25,2,2,
2,3,3,0,2,
0,0,25,3,3,

Paint
1,1,-134525072,-23,1,
1,1,2,1,25,
1,1,3,-20,2,

Assembly
1,0,1,0,1,
2,1,0,2,1,
0,2,2,1,1,

So, as you said before KanbanBoard needs some attention. More than likely (obviously even) the Kanban Board is either not getting the correct value or is referencing the wrong array item.

Digging in now.. bbl

chococrack 74 Junior Poster

I was prepared for the possibility that they would solve nothing. Alright I'm going to look at your code a little bit more and see if I can find anything else.

chococrack 74 Junior Poster

Don't know how useful this is to anyone else, but I made a pdf set up for easy reading on my Irex Iliad digital book reader. I'm sure some of you have some Kindles or Sony Readers or whatever.

Anyway, here you go, my pdf I made of Narue's post. (By the way if you feel this is in some way a violation of your work feel free to remove it)

chococrack 74 Junior Poster

Plu-cha... before I go diving into analyzing 2d arrays and such, I want to see if maybe the following easy fixes help anything:

-- Semi-colons.

while(roundNum<column)
	{
		cout<<"Enter Assembly numbers for round "<<roundNum+2<<endl;
		for (int x=0;x<row;x++)
		{
			cin>>assembly[x][roundNum];
		}
		roundNum++;
	};  // you dont need me  <--------------------------------- look
void getStartState(char* a, int** b)
{
...

};  < -------------------------------------------  me either
void printArray(char* a, int** b)
{

...

};  < --------------------------------------------------  me either

void updateWarehouse(int** warehouse, int** paint, int** assembly)
{

...

};  < ------------------------------------------------------  me either

void updateKanbanBoard(int** kanban, int** assembly, int**temp)
{

...

};  < -----------------------------------------  me either

void updatePaint(int** kanban, int** paint, int** temp)
{

...

};  <------------------------------------- me either

See if that helps any

chococrack 74 Junior Poster

I get lots of pretty output, (gcc compiler):

..-1208080203-1208080202-1208080201-1208080200-1208080199-1208080198-1208080197-
1208080196-1208080195-1208080194-1208080193-1208080192-1208080191-1208080190-
1208080189-1208080188-1208080187-1208080186-1208080185-1208080184-1208080183-
1208080182-1208080181-1208080180-1208080179-1208080178-1208080177-1208080176-
1208080175-1208080174-1208080173-1208080172-1208080171-1208080170-1208080169-
1208080168-1208080167-1208080166-1208080165-1208080164-1208080163-1208080162-
1208080161-1208080160-1208080159-1208080158-1208080157-1208080156-1208080155-
1208080154-1208080153-1208080152-1208080151-1208080150-1208080149-1208080148-
1208080147-1208080146-1208080145-1208080144-1208080143-1208080142-1208080141-
1208080140-1208080139-1208080138-1208080137-1208080136-1208080135-1208080134-
1208080133-1208080132-1208080131-1208080130-1208080129-1208080128-1208080127-...[/quote]

#include<iostream.h>

While it does not really matter if your compiler supports this, its usually a better idea to use the most recent header files

#include <iostream>

...

cout.fill('.');
for(i=i;i<10;++i)
{
    cout.width(i);
    cout.fill('.');
    cout<<i;
}

INT X: You declare a variable and do not initialize it.

FOR X = X: You copy the value of X into X,

FOR (X to 10): Well based on the value we gave X (none) this could be anywhere in the range of integer values ( -2147483648 to 2147483647, on a 32-bit system ) number of iterations.

int x = 0;
for(i = x; i<10; ++i)
   cout << "." << i;

~ or ~

for(int i=0; i<10; i++)
    cout << "." << i;

Would accomplish what you're looking for in your loop.

There is no return 0; The system needs this value to know everything went 'ok' with the system.. any other value that is returned is usually viewed as an error.

return 0;
chococrack 74 Junior Poster

A common main function appears as

int main()
{
    // code
    return 0;
}

Yours appears like this:

int main()
{
// little bit of code
    { // unecessary brackets
        if(some contidion)
            return Function1; // trying to return a value
        else
            return Function2; // trying to return a value
    } // more unessary brackets
// more code
}  // oops no return 0

You need to take out the brackets and give the functions something to store the values in (and pass their parameters.

int main()
{
    int getRecurs, getItera;
// ...
    if (input==1)
        getRecurs = recursiveGCD(PUT PARAMETERS!!!);
    
    if (input == 2)
        getItera = iterativeGCD(PARAMETERS);
// ....
return 0;
}

I still love you, even if no one else does :)

chococrack 74 Junior Poster
int recursiveGCD(int ,int );   
int iterativeGCD(int ,int );
int input;

The first two are fine (function prototypes).

However the last line
int input;
when I was first reading I was thinking perhaps it was meant to be a function. If that was the original intention, then you would have needed the necessary parenthesis to have it appear as a function

int input();

HOWEVER, the way you're using it you want to go with what Lokolo said in the above post, declare input in your main function

int main
{
    int input;
...
}