1. Doubly linked list
Https://github.com/BodhiXing/Data_Structure
2. Shuffling Machine
https://pta.patest.cn/pta/test/17/exam/4/question/264
Ideas:
Code:
1#include <iostream>2 using namespacestd;3 4 #defineMaxcard 545 6 stringINT2STR (intx)7 {8 Charch[4];9sprintf (CH,"%d", x);Ten returnch; One } A - voidShuffling (string* STR,Const int*ConstOrd) - { the inti; - stringTmp[maxcard]; - - for(i=0; i<maxcard;i++) +Tmp[ord[i]] =Str[i]; - for(i=0; i<maxcard;i++) +Str[i] =Tmp[i]; A } at intMain () - { - intnum,i; - stringCard[maxcard]; - intOrder[maxcard]; -Cin>>num; in - stringstr; to for(i=0;i< -; i++) + { -str = INT2STR (i+1); theCard[i] ="S"+str; *card[i+ -] ="H"+str; $card[i+ -] ="C"+str;Panax Notoginsengcard[i+ the] ="D"+str; - } thecard[ the] ="J1"; +card[ -] ="J2"; A the for(i=0; i<maxcard;i++) + { -Cin>>Order[i]; $order[i]--;//and array subscript consistent 0...53 $ } - - for(i=0; i<num;i++) the Shuffling (card,order); - Wuyi for(i=0; i<maxcard-1; i++) thecout<<card[i]<<" "; -cout<<Card[i]; Wu - return 0; About}
Shuffling machine and doubly linked list