Hi, my summative is due tomorrow and the program i was doing is just totally messed. So please if anyone can help me, i need a program with two function definitions, one recursive function, a string and usage of string functions, as well as one array. I really need this one guys! the requirement is to try and do it as a math lesson, so im guessing a trigonometry question or something along the lines is the best.
What problem is to be solved, exactly?
I'm assuming the ins and outs are expected to be handled with <iostream>
If you can't get any help from somebody more experienced, I'll help you...but here's what I suggest:
Array = Random array of numbers
Function #1 = Reads in the array of numbers and calls the Recursive function for each of them. Returns a new array that contains the output values from the recursive function.
Function #2 = Prints the output (and input, if you want) array(s) with cout
Recursive Function = Returns the factorial of the input integer/double.
personally, im not a very good programmer, which is why i did horrible on my first 2/3 days to do my summative. but we are required to create a some sore of math lesson using these requirements, parabola, trig, similar triangles,etc... anything of the sort, and i have so little time to do this myself which is why im stuck. im so sorry for the inconvenience but i really need this.
Here's something...
WARNING: I have not tested this and I'm not very good with C++ either yet. This may be buggy and not work properly...or perhaps it won't even compile. Or perhaps it works perfectly...I have no clue.
while (try != 'n')
{
int turns = 0;
cout << "Player 1 enter the character you would like to play with: ";
cin >> player[0];
while (player[0] == ' ' || player[0] == ' ')
{
cout << "Do not enter a space, enter a character: ";
cin >> player[0];
}
cout << endl << "Player 2 enter the character you are going to use (no spaces): ";
cin >> player[1];
while (player[1] == ' ' || player[1] == ' ')
{
cout << "Do not enter a space, enter a character: ";
cin >> player[1];
}
while (turns != 9 && !gameWon)
{
int x;
int y;
cout << endl << endl;
bool first = true;
bool second = true;
while (first && turns != 9)
{
first = false;
showTable(int x, int y);
cout << endl << "Player 1: Enter 2 numbers (1-3) to place your symbol: ";
cin >> x >> y;
while (x > 3 || x < 1 || y > 3 || y < 1)//user can't enter anything less or more than number 1-3
cout << "You must enter numbers from 1 to 3, enter again: ";
cin >> x >> y;
}
if (board[x - 1][y - 1] != ' ') //user has to enter in an empty space
{
first = true;
cout << "That spot is already taken." << endl ;
}
else
{
board[x - 1][y - 1] = player[0];
x = (x * 2) - 1;
y = (y * 2) - 1;
display[x - 1][y - 1] = player[0];
if (verifyWin(player[0])) gameWon = true; //call and statement,
turns++;
//places board position by substracting from each variable
}
}
}
cout << endl;
showTable(int x, int y);
if (verifyWin(player[0]))
cout << "Player 1 wins" <<endl;
else
if (verifyWin(player[1]))
cout <<"Player 2 wins" << endl;
else
cout<<"The game is a draw." << endl;
cout << "Would you like to play again? (y)?(n)?: ";
cin >> try;
I wrote it in gedit and just tested it with gcc and its really buggy. Buggy to the point where debugging it takes longer than actually writing it.
and Yocomp,
You're code spits errors left and right. You have variables with names that are reserved for the language. For example, inttry = 'y'
"try" is a C++ term and cannot be used as a variable name.
Also, you should organize your code...it's a trainwreck.