Shuffling Machine和双向链表
1. 双向链表
https://github.com/BodhiXing/Data_Structure
2. Shuffling Machine
https://pta.patest.cn/pta/test/17/exam/4/question/264
思路:
代码:
#include <iostream>
using namespace std; #define MAXCARD 54 string int2str(int x)
{
char ch[];
sprintf(ch,"%d",x);
return ch;
} void Shuffling(string* str,const int* const ord )
{
int i;
string tmp[MAXCARD]; for(i=;i<MAXCARD;i++)
tmp[ord[i]] = str[i];
for(i=;i<MAXCARD;i++)
str[i] = tmp[i];
}
int main()
{
int num,i;
string card[MAXCARD];
int order[MAXCARD];
cin>>num; string str;
for(i=;i<;i++)
{
str = int2str(i+);
card[i] = "S"+str;
card[i+] = "H"+str;
card[i+] = "C"+str;
card[i+] = "D"+str;
}
card[] = "J1";
card[] = "J2"; for(i=;i<MAXCARD;i++)
{
cin>>order[i];
order[i]--; //和数组下标一致 0...53
} for(i=;i<num;i++)
Shuffling(card,order); for(i=;i<MAXCARD-;i++)
cout<<card[i]<<" ";
cout<<card[i]; return ;
}
Shuffling Machine和双向链表的更多相关文章
- PAT自测-5 Shuffling Machine
原题连接https://pta.patest.cn/pta/test/17/exam/4/question/264 Shuffling is a procedure used to randomize ...
- 数据结构练习 00-自测5. Shuffling Machine (20)
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...
- 1042. Shuffling Machine (20) - sstream实现数字转字符串
题目例如以下: Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffli ...
- 自测-5 Shuffling Machine
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...
- PAT 1042. Shuffling Machine (20)
1042. Shuffling Machine (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Shu ...
- PAT1042:Shuffling Machine
1042. Shuffling Machine (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Shu ...
- A1042. Shuffling Machine
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...
- 1042. Shuffling Machine (20)
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...
- 00-自测5. Shuffling Machine
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...
随机推荐
- Search Insert Position
int searchInsert(int* nums, int numsSize, int target) { ; ); ; int mid; while(low<=high){ mid=(lo ...
- Substring with Concatenation of All Words
You are given a string, s, and a list of words, words, that are all of the same length. Find all sta ...
- [课程设计]Scrum 1.7 多鱼点餐系统开发进度
[课程设计]Scrum 1.7 多鱼点餐系统开发进度(点餐菜式内容添加及美化) 1.团队名称:重案组 2.团队目标:长期经营,积累客户充分准备,伺机而行 3.团队口号:矢志不渝,追求完美 4.团队选题 ...
- (转)Image Segmentation with Tensorflow using CNNs and Conditional Random Fields
Daniil's blog Machine Learning and Computer Vision artisan. About/ Blog/ Image Segmentation with Ten ...
- Sort merge join、Nested loops、Hash join(三种连接类型)
目前为止,典型的连接类型有3种: Sort merge join(SMJ排序-合并连接):首先生产driving table需要的数据,然后对这些数据按照连接操作关联列进行排序:然后生产probed ...
- C# 多线程详解 Part.04(Lock、Monitor、生产与消费)
系列1 曾经说过:每个线程都有自己的资源,但代码区是共享的,即每个线程都可以执行相同的函数. 这可能带来的问题就是多个线程同时执行一个函数,并修改同一变量值,这将导致数据的 ...
- SSH 端口转发+内网穿透
用最直白的语言对本文所有内容进行定义: 端口转发(-L):用A机器(内网)登录B机器(公网), 在A机器打开端口,将收到的所有请求转发到B机器的某个端口 (在代理机上执行) 内网穿透(-R):用A机器 ...
- Eclipse启动tomcat时出现报错-拒绝访问
今天新建项目,当选择项目的发布路径为tomcat的路径时 启动tomcat出现如下错误: Publishing the configuration... Error copying file to D ...
- 【原创】刚刚发现的SVN的几个有用的功能
一.可看到一个文件/目录跨Branch的所有变更历程 二.SVN可自动利用Word2013的审阅功能对比docx文档
- Ubuntu 16.04 风扇特别响解决办法
主要原因是显卡驱动的问题,选择驱动专有,tested.