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.
#include<iostream>
usingnamespace 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;
elseif (triple > 6)
cout << " at least 2 triples" << endl;
elseif (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.
@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.