I want to prompt the user for 9 integers between 1 and 9, and I want to output whether the integers are valid or invalid, depending on whether there is one of each number or not. Here is my code now:
#include <iostream>
#include "conio.h"
using namespace std;
int main(){
int sudoku[9] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int input;
int check[9];
for (int i = 0; i < 9; i++){
cout << "Enter 9 digits between 1 and 9: ";
cin >> input;
if (input > 1 || input > 9){
cout << "incorrect";
}
check[input-1]++;
}
if (check != { 1, 2, 3, 4, 5, 6, 7, 8, 9 }){
cout << "incorrect";
}
else if (check == {1, 2, 3, 4, 5, 6, 7, 8, 9}){
cout << "correct";
}
_getch();
return 0;
}
So I'm pretty sure I know what's wrong: The check array. However, I don't know how to fix it. Any advice? I'm a beginner, so I don't know a lot of code.
EDIT: Sorry, I'm not sure what kind of question I should ask instead on stack overflow. What I wanted to know was how to check if arrays contain numbers in the exact order.