C语言程序设计题 大家帮帮忙

来源:百度知道 编辑:UC知道 时间:2024/06/29 01:27:41
有事先准备好的一个数(一个100以内的两位数吧,为了使这个游戏更简单。),请玩游戏者来猜这个数,如果猜大了,我会提示你“请输入一个小一些的数”,反之,会提示你“输入一个大一些的数”,直到你猜对为止。根据你猜得次数,会给你一个评价性的结论,比如说你猜得次数小于5次,会说 “你很聪明”,反之,“你很笨哦”。重点是我想重复玩怎么办?
#include "math.h"
#include "conio.h"
main()
{int a,x,n=0;
clrscr();
x=rand()%90+10;
do
{n++;
printf("input a:");
scanf("%d",&a);
if(a>x)
printf("input a small one");
if(a<x) printf("input a bigger one");
}
while(a!=x);
printf("\n");
if(x==a)
if(n<=5)printf("\%d,you are very clever",n);
else printf("\n%d,you are foolish",n);
getch();
}

main()
{int i=67,count=0,temp;
printf("请输入一个数:");
do
{scanf("%d",&temp);
count++;
if(temp!=i)
else
if(temp>i)
printf("请输入一个小一些的数\n");
else
printf("请输入一个大一些的数\n");
}while(temp==i)
if("count>5")
printf("\n你很笨哦");
else
printf("\n你很聪明");

}

上面的是我用do--while()写的,因为是在网吧里,没有安装C语言编译程序,也没有经过调试,如果有错的地方,请见晾!

想重复就加个循环,打印一个选项菜单,继续玩选1,退出选0
你把你原来的代码发来,马上给你加好

#include "stdio.h"
#include "math.h"
#include "conio.h"
main()
{
int a,x,n;
int ag;
while(1)
{
clrscr();
n=0;
x=rand()%90+10;
do
{n++;
printf("input a:");
scanf("%d",&a);
if(a>x)
printf("input a small one");
if(a<x) printf("input a bi