求教一道c语言题?c语言高手请进。急急急!!!!!!

课题:猜数游戏(cs.c)

功能要求:计算机产生随机数,猜中即胜,猜不中,提示是大了还是小了,继续猜,直至猜到,给出所用时间和评语。

界面要示:简洁
要求提供完整的c语言程序,并根据你的算法画出完整的流程图来。源程序经编译通过并有完整流程图者,将追加10分。

现在公司项目忙,没时间上百度写程序了,简单写了一下,剩下的你完善!

#include <stdlib.h>
#include <stdio.h>
#include <time.h>

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;
}
}
温馨提示:内容为网友见解,仅供参考
第1个回答  2008-01-17
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
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<num)
printf("The number you guess is smaller than the guessed number!\n");
}while(num!=guess);
printf("Your guess is right!Congratulations!");
system("Pause");
}
第2个回答  2008-01-17
#include <stdlib.h>
#include <stdio.h>
#include <time.h>

int a:
a = srand((unsigned) time(&t)) % 10;
//产生0到9的随机数

估计你就不会在这,现在这个程序简单了
第3个回答  2008-01-17
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
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(g<i)printf("\n您猜的数字小了。请重输入:");
scanf("%d",&g);
j++;
}
t=time(NULL)-t;
printf("\n恭喜您!回答正确。你猜了%d次,用时%d秒。\n",j,t);
}
第4个回答  2008-01-17
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
#include <sys/timeb.h>

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();

}
第5个回答  2008-01-17
自己好好练练吧,不错的题目。
相似回答
大家正在搜