加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

【HDU 3328】【数据结构】Flipper

发布时间:2020-12-15 05:57:32 所属栏目:安全 来源:网络整理
导读:就是一个翻牌子的问题,写的略繁琐,因为只是实验室水题,所以不优化了,L是从最左翻面并且覆盖到第二堆上,以此类推,模拟就好。 [cpp] view plain copy print ? #include"stdio.h" #include"stack" #include"queue" using namespace std; int main( int ar



就是一个翻牌子的问题,写的略繁琐,因为只是实验室水题,所以不优化了,L是从最左翻面并且覆盖到第二堆上,以此类推,模拟就好。


[cpp] view plain copy
print ?
  1. #include"stdio.h"
  2. #include"stack"
  3. #include"queue"
  4. usingnamespacestd;
  5. intmain(intargc,charconst*argv[])
  6. {
  7. intn;
  8. intcas=1;
  9. while(~scanf("%d",&n)&&n)
  10. getchar();
  11. intlnum=1;
  12. intrnum=n;
  13. intPoker[105];
  14. stack<int>s1,s2,s3;
  15. charsta,ope;
  16. for(inti=1;i<=n;++i)
  17. scanf("%c",&sta);
  18. if(sta=='D')
  19. Poker[i]=0;
  20. else
  21. Poker[i]=1;
  22. }
  23. s1.push(1);
  24. s2.push(n);
  25. inti=1;i<n;++i)
  26. if(ope=='L')
  27. {
  28. intj=1;j<=lnum;++j)
  29. if(Poker[j])
  30. Poker[j]=0;
  31. Poker[j]=1;
  32. lnum++;
  33. if(lnum==rnum)
  34. while(!s2.empty())
  35. inttemp2=s2.top();
  36. s2.pop();
  37. s1.push(temp2);
  38. }
  39. while(!s1.empty())
  40. inttemp1=s1.top();
  41. s1.pop();
  42. s3.push(temp1);
  43. break;
  44. queue<int>temp;
  45. temp.push(lnum);
  46. temp.push(temp1);
  47. while(!temp.empty())
  48. inttemp1=temp.front();
  49. temp.pop();
  50. s1.push(temp1);
  51. if(ope=='R')
  52. intj=n;j>=rnum;--j)
  53. if(Poker[j])
  54. Poker[j]=0;
  55. else
  56. Poker[j]=1;
  57. rnum--;
  58. if(lnum==rnum)
  59. while(!s1.empty())
  60. inttemp1=s1.top();
  61. s1.pop();
  62. s2.push(temp1);
  63. while(!s2.empty())
  64. inttemp2=s2.top();
  65. s2.pop();
  66. s3.push(temp2);
  67. break;
  68. int>temp;
  69. temp.push(rnum);
  70. temp.push(temp2);
  71. while(!temp.empty())
  72. inttemp2=temp.front();
  73. temp.pop();
  74. s2.push(temp2);
  75. printf("Pile%dn",cas++);
  76. intnum;
  77. inta[1000];
  78. intb[1000];
  79. intbnum=1;
  80. while(!s3.empty())
  81. inttemp=s3.top();
  82. b[bnum++]=temp;
  83. s3.pop();
  84. scanf("%d",&num);
  85. inti=0;i<num;++i)
  86. printf("Card%disaface",a[i]);
  87. if(Poker[b[a[i]]])
  88. printf("up");
  89. printf("down");
  90. printf("%d.n",b[a[i]]);
  91. return0;
  92. }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读