#include "stdio.h"
#include "stdlib.h"
void main()
{
int num=rand()%100;
int guess;
int i=0;
printf("Guess a number (1-100):");
while(1)
{
scanf("%d",&guess);
i++;
if(i>塌正=10)
{
printf("Sorry, game over!\n");
break;
}
if(guess==num)
{
printf("You are right, guess %d times.\n",i);
break;
}
else if(guess>坦衫源num)
printf("Guess too big, try again:");
else
printf("让态Guess too small, try again:");
}
}
#include
#include
using namespace std;
int main()
{
char choice;
int i=0;
int number;
int n;
cout<<"圆毕请猜1—100的整数:"<
{srand((unsigned )time(NULL));
n=rand()%100+1;
while(cin>>number)
{
i++;
if(i==10)
{
cout<<"你猜的次橘没芹数已达10次,此次结束。"<
}
if(number>n)
{
cout<<"你猜大了察斗"<
}
else if(number
cout<<"你猜小了"<
}
else
{
cout<<"你猜对了"<
}
}
i=0;
do
{
cout<<"是否继续?是请按y/否请按n。"<
}while(choice!='y' &&choice!='n');
if(choice=='n')
{
return 0;
}
}
}