Array problem

I don't know how to even start this one.
The problem states:

Ask the user for 9 values, either ‘X’ or ‘O’. Check the user input as it is entered. Once the data is entered, process the array to check to see if there are any occurrences of 3 letter X’s. Use the following examples as a guide.

Please enter an X or O for position 0: X
Please enter an X or O for position 1: X
Please enter an X or O for position 2: A
Please follow the directions!
Please enter an X or O for position 2: O
Please enter an X or O for position 3: O
Please enter an X or O for position 4: X
Please enter an X or O for position 5: X
Please enter an X or O for position 6: O
Please enter an X or O for position 7: O
Please enter an X or O for position 8: X
Your answers were: XXOOXXOOX
There are no triples in this data.


Please enter an X or O for position 0: X
Please enter an X or O for position 1: X
Please enter an X or O for position 2: O
Please enter an X or O for position 3: O
Please enter an X or O for position 4: X
Please enter an X or O for position 5: X
Please enter an X or O for position 6: X
Please enter an X or O for position 7: O
Please enter an X or O for position 8: X
Your answers were: XXOOXXXOX
There is at least one triple X in this data.

Begin by creating an array of character, that is 9 big. Create a variable char answer;

That the user can enter his answer in. Ask the user using cout Use a for loop to use 9 times.

I was bored. Here it is.

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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include<iostream>

using namespace std;

int main(){

	bool condition = true;
	char inputarray[8];
	char input;
	int triple = 0;
	int count = 0;

	
		for (int i = 0; i < 9; i++)
		{
			cout << "Please enter an X or O for position " << i << ":"; cin >> input;
			while ((input != 'X') && (input!= 'x') && (input != 'o') && (input != 'O'))
			{
				cout << "\nPlease follow the directions!" << endl;
				cout << "Please enter an X or O for position " << i << ":"; cin >> input;			
			}
			 inputarray[i] = input;
		}



		cout << "\nYour answer is: ";
		for (int i = 0; i < 9; i++)
			cout << inputarray[i] << " ";

		for (int i = 0; i < 9; i++)
		{
			if (inputarray[i] == 'X')
				triple++;
			if (triple > 3)
				count++;
		}

		cout << "\nThere is ";
		if (triple > 3)
			cout << " at least 1 triple" << endl;
		else if (triple > 6)
			cout << " at least 2 triples" << endl;
		else if (triple == 9)
			cout << "at least 3 triples" << endl;
		else
			cout << "no triples" << endl;


	system("pause");
	
}

@Shamieh You might think that you're helping him, but you're not, you're just doing his homework and it will only hurt him in the long run, trust me Ive seen many cases. So next time, follow the rules, and dont do peoples homework.
Thanks for the help @Shamieh but I figured it out. But @TarikNeaj is right. I need to understand what I'm doing.
@TarikNeaj it was not stated that this was a Homework problem, it said "the problem states," so I didn't break any rules. Secondly, @calisabeth you are indeed correct, you need to understand what you are doing but you obviously don't even know how to create an array. Instead of me holding your hand exhaustively on each step - you should look at the above code posted, which is easily decipherable, and try to understand what each algorithm is doing. Also, if this is a "Homework" assignment and you are in a introductory programming class, then none of this should be hard for you to grasp and figure out. I can't do the thinking for you, but I can help you so that you can tackle harder problems with what you now know for next time. Also, @TarikNeaj you've been reported since you like to follow everything I post on and report me for no reason.

Have a good day,

Sham
Last edited on
Sham. Use your brain. Read his post. A monkey would know its homework.
Refer to my above post @TarikNeaj
Topic archived. No new replies allowed.