#include
#include
#include
int main(void)
{
int a,b,i=0;
int t=0,d=10;
srand(time(NULL)); /*初始化随机数种子*/
a=rand()%(d-t+1)+t; /*生成一个[0 10]区间内的整数*/
printf("you have three times to answer:\n");
do{scanf("%d\n",&b);
i++;
if(a==b) printf("you are right\n");
else printf("error\n");
}while((a!=b)&&(i<3));
if(i=3) printf("the right answer is:%d\n",a);
}
#include
#include
using namespace std;
int randNum();
void main()
{
int num;
int randnum = randNum();
cout << randnum;
cin >> num;
if (randnum != num )
{
cout << "ERROR";
}
else
cout << "OK";
}
int randNum()
{
srand(time(NULL));
int num = rand();
num = num % 10;
return num;
}