HELPPP! SUMMATIVE!

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.
We're not here to do your work for you, you know.
Provide more information, please.

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>

int factorial(int number) {
	if(number <= 1) return 1;
	return(number * factorial(number - 1));
}
void performFactorial(int nInput[], int *nOutput[])
{
	for(i=0;i<10;i++)
	{
		nOutput[i] = factorial(nInput[i]);
	}
}
void printArr(int *inpArr)
{
	std::cout << "These are the results of the factorial function:" << std::endl;
	for(i=0;i<10;i++)
	{
		std::cout << inpArr[i] << std::endl;
	}
}
int main(int argc,char *argv[])
{
	int nArray[] = {0,5,4,2,6,7,4,7,2,9}
	int nOutput[] = {0};
	nOutput = performFactorial(nArray);
	printArr(nOutput);
	return(0);
}
Last edited on
Don't be a tool, SmallTock. Don't do this chump's homework for him.
currently working on this:

//need to create multiple blocks


#include <iostream>
#include <string>

using namespace std;

bool verifyWin (char);
int showTable (int, int);
char display [5][5] = { { ' ', '|', ' ', '|', ' ' }, { '-', '+', '-', '+', '-' }, { ' ', '|', ' ', '|', ' ' }, { '-', '+', '-', '+', '-' }, { ' ', '|', ' ', '|', ' ' } };

int main (){

string game("Tic Tac Toe");
cout<<game<<endl;


char board [3][3] = { { ' ', ' ', ' ' }, { ' ', ' ', ' ' }, { ' ', ' ', ' ' } },
player[2] = { ' ', ' ' },
int try = 'y';

bool gameWon = false;

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;

if (try != 'n')

for (int x = 1; x <= 3; x++)

for (int y = 1; y <= 3; y++)


board[x - 1][y - 1] = ' ';

display[(x * 2) - 2][(y * 2) - 2] = ' ';

}




cout<<endl;


return 0;
}

Relax, disch.

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,
int try = 'y'
"try" is a C++ term and cannot be used as a variable name.

Also, you should organize your code...it's a trainwreck.
Last edited on
Topic archived. No new replies allowed.