急!!怎样实现以下功能????

来源:百度知道 编辑:UC知道 时间:2024/07/05 14:21:58
1输入感叹号退出。
2输入出了0 1 2 3 4 5 6 7 8 9和感叹号外。都printf("puterror!");
#include <stdio.h>
#include <stdlib.h>
guess()
{
int i,g,t=0;
randomize();
i=random(10);
printf("-----------Welcome to Guessing Numbers Game.(putin ! to out)--------\n");
i=rand()%10;
printf("-----------Please Input the number you guess(0-9)------------ \n");
scanf("%d",&g);
if (g==33) exit(0);
if (g<0) printf("puterror!\n");
if (g>9) printf("puterror!\n");
while(g!=i)
{
if(g<i)
{
printf("Bigger,Please!\n");
t++;
scanf("%d",&g);
}
else
{
printf("Smaller,Please!\n");
t++;
scanf("%d",&g);
}
}
t++;

printf("The random number is %d

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
guess()
{
int realvalue,guessnumber,guesstimes=0;
char temp,*p;
srand((unsigned) time(NULL));
realvalue=rand()%10+1;

printf("-----------Welcome to Guessing Numbers Game.(putin ! to out)--------\n");
printf("\n");

while(1)
{
printf("-----------Please Input the number you guess(0-9)------------ \n");
fflush(stdin);
scanf("%c",&temp);
if (temp=='!') exit(0);
if (temp<'0'||temp>'9')
printf("put error!\n");
p=&temp;
guessnumber=atoi(p);

if(guessnumber==realvalue)
{
printf("YOU WIN!\n");
guesstimes++;
break;
}
else
{
if(guessnumber<realvalue)
printf("Your number samller than