"int main()"에 대한 괄호 안에 "임의"를 선언하는 방법을 모르며 도움이 필요합니다. (저는 C++ 초보자입니다.)C++ 추측 게임 오류
제 코드를 살펴보고 사용해보십시오.이 문제를 해결하는 방법을 알고 있다고 생각되면 답변을 보내주십시오. 그것은 나에게 많은 것을 의미 할 것입니다. 감사! 한편, 나는 문제를 스스로 해결하려고 계속 노력할 것이다.
참고 : 구체적으로 사용하려면 Code :: Blocks를 사용하고 있습니다.
오류는 내 코드 7/9에 있습니다.
|| === 빌드 : 디버그 추측의 수 (컴파일러 : GNU GCC 컴파일러) ===
다음#include <iostream>
#include <stdlib.h>
#include <conio.h>
using namespace std;
int main()
{
int rn = random() % 21; // generates a random int from 0 to 20
// First output asking the user to guess the number
cout << "Please guess my number :" << endl;
int u;
cin >> u;
while (u != rn) // Calculates the answer that you give
{
// If the user's number is greater than the random number
// the program will let you know it's too large
if (u > rn)
{
cout << "You guessed too big!" << endl;
}
// On the other hand, if the user guesses to small
// the program will tell them that it's too small
else if (u < rn)
{
cout << "You guessed too small!" << endl;
}
// If the user does not get the right number, the program
// will tell the user to guess again
cout << "Please guess again :" << endl;
cin >> u;
}
// If the user guesses the number correctly, the program
// will say that they got it right, and end the program
cout << "You guessed it right!" << endl;
getch();
}
업데이트 된 컴파일러 오류입니다 : 여기
은 아래에있는 내 업데이트 된 코드입니다 |C : \ Users \ Minecraftship \ Documents \ CPP 프로그램 책 \ 추측에서 번호 \ main.cpp || 함수에서 'int main()': |
C : \ Users \ Minecraftship \ Documents \ CPP 프로그램 책 \ 추측에서 번호 \ main.cpp | 12 |
오류 : 'randomize'가이 범위에서 선언되지 않았습니다.
|| === 실패 빌드 : 1 오류 (들), 0 경고 (들) (0 minute (s)을 0 초 (들)) === | 문제는
은 컴파일러가 당신을 말해 주는가를 무슨 일이야? 그렇다면 그 정보가 도움이 될 것입니다. –
6 행에 세미콜론이 있는데 여기에는 속하지 않습니다. int main(); – yussuf
이'while (u = rn)'은 용의자로 보입니다 –