Czy moze ktos mi powiedziec i wyjasnic co jest nie tak z tym kodem, ze wywala mi liczby z kosmosu?
#include <iostream>
using namespace std;
struct Question {
int a, b;
};
int get_answer(Question question) {
return question.a * question.b;
}
Question get_question() {
Question question;
question.a = 1 + rand() % 10;
question.b = 1 + rand() % 10;
return question;
}
void print_question(Question question) {
cout << question.a << " * " << question.b << " = ";
}
void ask_questions(Question questions[], int number) {
for (int index = 0; index < number; index++) {
int answer;
do {
print_question(questions[index]);
cin >> answer;
} while (answer != get_answer(questions[index]));
}
}
void draw_questions(Question questions[], int number)
{
for (int index1 = 0; index1 < number; index1++)
{
int index2;
questions[index1] = get_question();
}
}
int main()
{
Question questions[10];
draw_questions(questions, 10);
ask_questions(questions, 10);
return 0;
}