#include
<stdio.h>
int
games(const int i);
int
main(void)
{
const int
data = 0;
int
count;
do{
printf("输入一个要猜的数值,不要大于1000:");
scanf("%d",&data);
}while (data > 1000);
for (count = 0; count < 5;count++)
{
switch (games(data))
{
case
-1 : printf("价格低了\n");break;
case
0
: printf("价格高了\n");break;
case
1
: count = 10;break;
}
}
if(count < 5)
printf("对不起猜数次数到了!\n");
else
printf("恭喜你猜对了!\n");
return
0;
}
int
games(const int i)
{
int
k;
printf("请输入猜值:");
scanf("%d",&k);
if (k > i)
return
0;
else
if (k == i)
return
1;
else
return -1;
}
[
本帖最后由 nzxiansheng 于 2012-6-2 21:10 编辑 ]