誰かが間違えるまで、1 から 9 までの数字を使った掛け算の質問を繰り返すゲームを作成しようとしています。それらが間違っている場合、プログラムは「oops」を表示するはずです。
私のコード:
#include <iostream>
#include <time.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
int main ()
{
srand (time(NULL));
int a= rand()%9+1;
int b= rand()%9+1;
int c;
while (c == a*b)
{
cout<<a<<" * "<<b<<"= ";
cin>>c;
}
cout<<"oops";
return 0;
}
私は2つの困難を抱えています。まず、同じ「乱数」がプログラムで生成されます。第二に、誰かがミスをした場合、「おっと」は表示されません。
助けてくれてありがとう。