没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论













#include<stdio.h>
#include<stdlib.h>
#include <time.h>
int x[4],y[4];//x是计算机产生的数字,y是玩家输入的数字
void begin(void);//初始页
void start(void);//开始游戏
void creat_num(void);//创建数字
int judgenum(int *n);//判断输入数字是否正确
int judgeA(int *a,int *b);//获取A
int judgeB(int *a,int *b);//获取B
void win(void);//赢游戏
void lose(void);//输游戏
/*************************************************************************/
int main() /*主函数*/
{
char PRESS; /*按键变量*/
int i,A,B,outwhile=0; /*outwhlie为跳出循环标志*/
begin(); /*显示初始页面和游戏说明*/
do
{
scanf("%c",&PRESS); /*获取按键*/
fflush(stdin); /*清除缓存*/
switch(PRESS)
{
case 'e':case 'E':exit(0);break; /*退出*/
case 's':case 'S': /*是开始键*/
#include<stdlib.h>
#include <time.h>
int x[4],y[4];//x是计算机产生的数字,y是玩家输入的数字
void begin(void);//初始页
void start(void);//开始游戏
void creat_num(void);//创建数字
int judgenum(int *n);//判断输入数字是否正确
int judgeA(int *a,int *b);//获取A
int judgeB(int *a,int *b);//获取B
void win(void);//赢游戏
void lose(void);//输游戏
/*************************************************************************/
int main() /*主函数*/
{
char PRESS; /*按键变量*/
int i,A,B,outwhile=0; /*outwhlie为跳出循环标志*/
begin(); /*显示初始页面和游戏说明*/
do
{
scanf("%c",&PRESS); /*获取按键*/
fflush(stdin); /*清除缓存*/
switch(PRESS)
{
case 'e':case 'E':exit(0);break; /*退出*/
case 's':case 'S': /*是开始键*/
start(); /*开始新游戏*/
for(i=1;i<=8;i++) /*循环8次*/
{
y[0]=y[1]=y[2]=y[3]=-1;/*输入前使y置于-1*/
printf("\n请输入第%d个四位数,各位之间以空格隔开:",i);
do
{
scanf("%d%d%d%d",&y[0],&y[1],&y[2],&y[3]);
fflush(stdin);/*清除缓存*/
if(judgenum(y)==0) /*判断输入是否合法*/
printf("输入数字不合法,请重新输入:");
}while(!judgenum(y));
A=judgeA(x,y); /*获取A*/
B=judgeB(x,y); /*获取B*/
if(A==4)break; /*如果A等于4,跳出循环*/
printf("%dA%dB\n",A,B);
printf("继续输入(c) 看答案(a) 离开(e)\n");
outwhile=0; /*置零*/
while(outwhile==0)
{
scanf("%c",&PRESS);
fflush(stdin); /*清除缓存*/
switch(PRESS)
{
case 'c':case 'C':outwhile=1;break;/*继续输入*/
case 'a':case 'A':outwhile=1;goto out;break;/*看答案,认输*/
case 'e':case 'E':outwhile=1;exit(0);break;/*退出游戏*/
default :printf("输入错误,请重新输入:");break;/*输入错误*/
}
}
for(i=1;i<=8;i++) /*循环8次*/
{
y[0]=y[1]=y[2]=y[3]=-1;/*输入前使y置于-1*/
printf("\n请输入第%d个四位数,各位之间以空格隔开:",i);
do
{
scanf("%d%d%d%d",&y[0],&y[1],&y[2],&y[3]);
fflush(stdin);/*清除缓存*/
if(judgenum(y)==0) /*判断输入是否合法*/
printf("输入数字不合法,请重新输入:");
}while(!judgenum(y));
A=judgeA(x,y); /*获取A*/
B=judgeB(x,y); /*获取B*/
if(A==4)break; /*如果A等于4,跳出循环*/
printf("%dA%dB\n",A,B);
printf("继续输入(c) 看答案(a) 离开(e)\n");
outwhile=0; /*置零*/
while(outwhile==0)
{
scanf("%c",&PRESS);
fflush(stdin); /*清除缓存*/
switch(PRESS)
{
case 'c':case 'C':outwhile=1;break;/*继续输入*/
case 'a':case 'A':outwhile=1;goto out;break;/*看答案,认输*/
case 'e':case 'E':outwhile=1;exit(0);break;/*退出游戏*/
default :printf("输入错误,请重新输入:");break;/*输入错误*/
}
}
剩余5页未读,继续阅读
资源评论


dlooo12345
- 粉丝: 5
- 资源: 1
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


安全验证
文档复制为VIP权益,开通VIP直接复制
