2019-05-30
#include<time.h>
#include<Stdlib.h>
#include<stdio.h>
void guessfigure(int x)
{ int magic,guess,i;
srand(time(NULL));
magic=rand()%100;
for(i=1;i<=x;i++)
{ printf(" Please guess a magic number:");
scanf("%d",&guess);
if(guess==magic)
{ printf(" Right! %dtimes",i);
return;
}
else if(guess>magic)
printf(" Wrong!Too high!");
else
printf(" Wrong!Too low!");
}
}
int main()
{ int x;
printf(" guess figure ");
char k;
int i=0;
do
{
if(i!=0)
printf("welcome to antother ");
x=10;
guessfigure(x);
printf(" exit: q; go-on:anyone else ");
scanf("%c",&k);
}while(k!='q');
return 0;
}
#include<time.h>
#include<Stdlib.h>
#include<stdio.h>
void guessfigure(int x)
{ int magic,guess,i;
srand(time(NULL));
magic=rand()%100;
for(i=1;i<=x;i++)
{ printf(" Please guess a magic number:");
scanf("%d",&guess);
if(guess==magic)
{ printf(" Right! %dtimes",i);
return;
}
else if(guess>magic)
printf(" Wrong!Too high!");
else
printf(" Wrong!Too low!");
}
}
int main()
{ int x;
printf(" guess figure ");
char k;
int i=0;
do
{
if(i!=0)
printf("welcome to antother ");
x=10;
guessfigure(x);
printf(" exit: q; go-on:anyone else ");
scanf("%c",&k);
}while(k!='q');
return 0;
}