struktura tabliczki mnozenia

0

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;
}
1

Co to znaczy z kosmosu?

U mnie działa w ten sposób:

4 * 7 = 28
8 * 6 = 48
4 * 6 = 24
7 * 3 = 21
10 * 2 = 20
3 * 8 = 24
1 * 10 = 10
4 * 7 = 28
1 * 7 = 7
0

Dziwne, bo u mnie w Visual Studio wyskakuje 8 cyfr......Widocznie to wina kompilatora.

1 użytkowników online, w tym zalogowanych: 0, gości: 1