이번 C++ 질문.C++ 두 난수 곱을 저장 중
두 임의의 숫자 사이에 제품을 저장하려고합니다 ... srand (time (0))를 기반으로 생성하고 -1 후에 종료하는 두 임의의 숫자 사이의 제품이 무엇인지 묻는 것으로되어 있습니다. 화면에 인쇄 할 때 루프를 입력뿐만 아니라
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <iomanip>
using std::setw;
#include <cstdlib>
using std::rand;
using std::srand;
#include <ctime>
using std::time;
int multiplication()
{
srand(time(0));
int x = 0;
while (x != -1)
{
int random_int;
random_int = (rand()%10 * rand()%10);
cout << "(Enter -1 to quit) \n";
cout << "" << rand() % 10 << " multiplied by " << rand() % 10 <<"? \n";
cin >> x;
if(x == random_int)
{
cout << "you're right!" << endl;
}
else
{
cout << "you're wrong" << endl;
}
}
return 0;
}
int main()
{
multiplication();
}
질문은 어디에 있습니까? –