c语言生成一个数,然后猜,猜了后有提示,猜对了可以继续猜,具体看我的,看看我错哪了,运行不到

Python022

c语言生成一个数,然后猜,猜了后有提示,猜对了可以继续猜,具体看我的,看看我错哪了,运行不到,第1张

修改后:

#include<stdio.h>

#include<time.h>

#include <stdlib.h>

char yz(int b)

main()

{

int shu

char jx

int system(const char *string)

do {

srand (time (NULL) )

shu = (1 + rand () % 1000)

printf("我一个数在1到1000之间。\n")

printf("你可以猜到这个数吗?\n")

jx = yz(shu)

system("cls")

} while ((jx == 'y') || (jx == 'Y'))

}

char yz(int b)

{

int a, d

char c

d = 0

while (d == 0)

{

printf("请输入你猜的数:")

scanf("%d", &a)

if (a == b)

{

printf("\n太棒了,你猜对了!")

d = 1

printf("\n还想继续吗?(Y/N)\n")

scanf("%s", &c)

}

else if (a >= b)

{

printf("\n太大了,再试。\n")

}

else

printf("\n太小了,再试。\n")

}

return c

}

用你写的程序改的

#include<stdio.h>

#include<stdlib.h>

#include<time.h>

int main()

{

    int a

int chai(int a)

printf("请输入你要猜的数字:")

printf("chai=%d\n",chai(a))

}

int chai(int a)

{int b,i=1

while(1)

{

        srand(time(NULL))

    a=rand()%100

while(i<=10)

{ scanf("%d",&b)

if(a==b)

{

printf("您猜了%d次才猜对此数",i)

return  a

}

else if(b>a)

printf("你猜的数字偏大请重新输入")

else

printf("你猜得数字偏小请重新输入")

i++

}

printf("\n刚才你要猜的正确数字是%d,你猜错了\n",a)

break

}

return 0

}