现在公司项目忙,没时间上百度写程序了,简单写了一下,剩下的你完善!
#include
#include
#include
void main( void )
{
int temp, n;
srand((unsigned)time(NULL));
temp=rand();
temp=temp%10;
a: printf("\输入你猜的数");
scanf("%d",&n);
if (temp == n)
{
printf("\n真聪明,猜对了!\n");
}
else if (n < temp)
{
printf("\n猜小了,继续猜!\n");
goto a;
}
else
{
printf("\n猜大了,继续猜!\n");
goto a;
}
}
#include
#include
#include
void main(void)
{
int num,guess;
srand((unsigned int)time(NULL));
num=rand()%500;
printf("%d\n",num);
do
{
printf("please input the number you guess:");
scanf("%d",&guess);
if(guess>num)
printf("The number you guess is larger than the guessed number!\n");
else if(guess
}while(num!=guess);
printf("Your guess is right!Congratulations!");
system("Pause");
}
#include
#include
#include
int a:
a = srand((unsigned) time(&t)) % 10;
//产生0到9的随机数
估计你就不会在这,现在这个程序简单了
#include
#include
#include
void main()
{
int i,g,j=1;
long t;
srand((unsigned)time(NULL));
i = rand() % 100;
printf("请输入您猜的数字(1-100):");
scanf("%d",&g);
t=time(NULL);
while(g!=i)
{
if(g>i)printf("\n您猜的数字大了。请重输入:");
if(gscanf("%d",&g);
j++;
}
t=time(NULL)-t;
printf("\n恭喜您!回答正确。你猜了%d次,用时%d秒。\n",j,t);
}
#include
#include
#include
#include
int ra(int b)
{
int a ;
int i;
a = rand()%100;
for( i = 0; i < 5 ;i++)
{
printf("Please input a number(0-100):\n");
scanf("%d",&b);
if(a == b)
{
printf("Bingo!\n");
printf("Answer is:%d",a);
break;
}else if( a > b)
{
printf("Less!\n");
}else if( a < b)
{
printf("More!\n");
}
if( i == 4)
{
printf("Game Overt!\n");
printf("Answer is:%d",a);
break;
}
}
return a;
}
void main()
{
timeb timebuf;
ftime(&timebuf);
time_t tm(timebuf.time);
srand(tm);
int c = 0 ;
ra(c);
getchar();
getchar();
}
自己好好练练吧,不错的题目。