小猫钓鱼
来源:互联网 发布:苹果社交软件色情 编辑:程序博客网 时间:2024/04/26 04:27
#include<bits/stdc++.h>
struct queue
{
int data[1000];
int head;
int tail;
};
struct stack
{
int data[10];
int top;
};
int main()
{
struct queue q1,q2;
struct stack s;
int book[10];
int i,t;
q1.head=1;
q1.tail=1;
q2.head=1;
q2.tail=1;
s.top=0;
for(i=1;i<=9;i++)
book[i]=0;
for(i=1;i<=6;i++)
{
scanf("%d",&q1.data[q1.tail]);
q1.tail++;
}
for(i=1;i<=6;i++)
{
scanf("%d",&q2.data[q2.tail]);
q2.tail++;
}
while(q1.head<q1.tail&&q2.head<q2.tail)
{
t=q1.data[q1.head];
if(book[t]==0)
{
q1.head++;
s.top++;
s.data[s.top]=t;
book[t]=1;
}
else
{
q1.head++;
q1.data[q1.tail]=t;
q1.tail++;
while(s.data[s.top]!=t)
{
book[s.data[s.top]]=0;
q1.data[q1.tail]=s.data[s.top];
q1.tail++;
s.top--;
}
}
t=q2.data[q2.head];
if(book[t]==0)
{
q2.head++;
s.top++;
s.data[s.top]=t;
book[t]=1;
}
else
{
q2.head++;
q2.data[q2.tail]=t;
q2.tail++;
while(s.data[s.top]!=t)
{
book[s.data[s.top]]=0;
q2.data[q2.tail]=s.data[s.top];
q2.tail++;
s.top--;
}
}
}
if(q2.head==q2.tail)
{
printf("小哼win\n");
printf("小哼当前手中的牌是");
for(i=q1.head;i<=q1.tail-1;i++)
printf(" %d",q1.data[i]);
if(s.top>0)
{
printf("\n桌上的牌是");
for(i=1;i<=s.top;i++)
printf(" %d",s.data[i]);
}
else
printf("\n桌上已经没有牌了");
}
else
{
printf("小哈win\n");
printf("小哈当前手中的牌是");
for(i=q2.head;i<=q2.tail-1;i++)
printf(" %d",q2.data[i]);
if(s.top>0)
{
printf("\n桌上的牌是");
for(i=1;i<=s.top;i++)
printf(" %d",s.data[i]);
}
else
printf("\n桌上已经没有牌了");
}
return 0;
}
struct queue
{
int data[1000];
int head;
int tail;
};
struct stack
{
int data[10];
int top;
};
int main()
{
struct queue q1,q2;
struct stack s;
int book[10];
int i,t;
q1.head=1;
q1.tail=1;
q2.head=1;
q2.tail=1;
s.top=0;
for(i=1;i<=9;i++)
book[i]=0;
for(i=1;i<=6;i++)
{
scanf("%d",&q1.data[q1.tail]);
q1.tail++;
}
for(i=1;i<=6;i++)
{
scanf("%d",&q2.data[q2.tail]);
q2.tail++;
}
while(q1.head<q1.tail&&q2.head<q2.tail)
{
t=q1.data[q1.head];
if(book[t]==0)
{
q1.head++;
s.top++;
s.data[s.top]=t;
book[t]=1;
}
else
{
q1.head++;
q1.data[q1.tail]=t;
q1.tail++;
while(s.data[s.top]!=t)
{
book[s.data[s.top]]=0;
q1.data[q1.tail]=s.data[s.top];
q1.tail++;
s.top--;
}
}
t=q2.data[q2.head];
if(book[t]==0)
{
q2.head++;
s.top++;
s.data[s.top]=t;
book[t]=1;
}
else
{
q2.head++;
q2.data[q2.tail]=t;
q2.tail++;
while(s.data[s.top]!=t)
{
book[s.data[s.top]]=0;
q2.data[q2.tail]=s.data[s.top];
q2.tail++;
s.top--;
}
}
}
if(q2.head==q2.tail)
{
printf("小哼win\n");
printf("小哼当前手中的牌是");
for(i=q1.head;i<=q1.tail-1;i++)
printf(" %d",q1.data[i]);
if(s.top>0)
{
printf("\n桌上的牌是");
for(i=1;i<=s.top;i++)
printf(" %d",s.data[i]);
}
else
printf("\n桌上已经没有牌了");
}
else
{
printf("小哈win\n");
printf("小哈当前手中的牌是");
for(i=q2.head;i<=q2.tail-1;i++)
printf(" %d",q2.data[i]);
if(s.top>0)
{
printf("\n桌上的牌是");
for(i=1;i<=s.top;i++)
printf(" %d",s.data[i]);
}
else
printf("\n桌上已经没有牌了");
}
return 0;
}
阅读全文
0 0
- 小猫钓鱼
- 小猫钓鱼偶感!
- 纸牌游戏-小猫钓鱼
- 纸牌游戏--小猫钓鱼
- 栈与队列,小猫钓鱼
- 小猫钓鱼游戏java实现
- [数据结构]纸牌游戏——小猫钓鱼
- 小猫钓鱼--栈和队列的使用
- C语言—算法—小猫钓鱼
- 2.3纸牌游戏——小猫钓鱼
- 算法入门——小猫钓鱼纸牌
- 纸牌游戏——小猫钓鱼
- 纸牌游戏——小猫钓鱼
- 学会了钓鱼的小猫来到了软件开发公司...
- 纸牌游戏——小猫钓鱼(阿哈!算法)
- 啊哈!算法—纸牌游戏—小猫钓鱼
- java实现纸牌游戏-小猫钓鱼算法
- 栈和队列的实际应用:小猫钓鱼
- java中的反射机制
- python urlopen 超时
- 82. Remove Duplicates from Sorted List II
- Vue.js安装配置
- Maven之(二)Maven生命周期
- 小猫钓鱼
- python基础教程
- CCF考试练习——201612-2
- AOP
- 静态方法、实例方法
- redis的使用场景
- javaEE13种核心技术
- fork,Process,Pool的比较
- 判断一个序列是否是该栈的弹出顺序