有人可以帮帮我吗?我是C编程的新手,我在repl.it中遇到一个编译问题,当我在CLion中运行我的代码时,它没有出现。
错误是: 退出状态-1
main.c:1:1:错误:预期的标识符或'('在数字常量之前 12 ^〜
/*
* Description: This is a multiplication problem generator, for children.
* Created By: Michael Isenhour
* Date Written: June 6th, 2018
*/
#include <stdio.h>
#include <stdlib.h>
int generateRandomNumber();
void askQuestion(int, int);
int main(void) {
srand(1712);
int counter = 0;
while (counter < 10) {
int randomlyGeneratedFirstNumber = generateRandomNumber();
int randomlyGeneratedSecondNumber = generateRandomNumber();
int answer = randomlyGeneratedFirstNumber * randomlyGeneratedSecondNumber;
int userAnswer;
askQuestion(randomlyGeneratedFirstNumber, randomlyGeneratedSecondNumber);
scanf("%d", &userAnswer);
while (userAnswer != answer) {
puts("No, Please try again");
askQuestion(randomlyGeneratedFirstNumber, randomlyGeneratedSecondNumber);
scanf("%d", &userAnswer);
}
puts("Very Good");
counter++;
}
return 0;
}
int generateRandomNumber() {
int result;
result = 1 + (rand() % 9);
return result;
}
void askQuestion(int firstNumber, int secondNumber) {
printf("How much is %d times %d\n", firstNumber, secondNumber);
}