Shuffling Machine (20)

Source: Internet
Author: User
Tags shuffle

The world still have shuffle machine this thing ...

The initial sequence of cards is: S1, S2, ..., S13, H1, H2, ..., H13, C1, C2, ..., C13, D1, D2, ..., D13, J1, J2

Give the number of Shuffle wheel N, and give a sequence to determine the shuffle once, each card position is where

Sample Input:2 $  the Panax Notoginseng  - 3  the  +  -  Wu  A  One  A  -  the  +  - 2 4  at  -  -  -  - 6 7 8  -  the  - Wuyi 9 Ten  -  the  - 5  -  -  + 1  -  +  A  -  in  -  to  +  -  the  *  $  $  -
Sample output:s7 C11 C10 C12 S1 H7 H8 H9 D8 D9 S11 S12 S13 D10 D11 D12 S3 S4 S6 S10 H1 H2 C13 D2 D3 D4 H6 H3 D13 J1 J2 C1 C2 C3 C4 D1 S5 H5 H11 H12 C6 C7 C8 C9 S2 S8 S9 H10 D5 D6 D7 H4 H13 C5

Give the Code ~ time complexity O (n) ... But the previous constant is the number of cards, it is quite big ...

Determine the position of a card after washing every time

#include <iostream>#include<string>using namespacestd;stringcard[ -] = {"",/*Initialize*/        "S1","S2","S3","S4","S5","S6","S7","S8","S9","S10","S11","S12","S13",/*this deck of cards*/        "H1","H2","H3","H4","H5","H6","H7","H8","H9","H10","H11","H12","H13",/*, beginning*/        "C1","C2","C3","C4","C5","C6","C7","C8","C9","C10","C11","C12","C13",/*left a*/        "D1","D2","D3","D4","D5","D6","D7","D8","D9","D10","D11","D12","D13",/*a vacancy*/        "J1","J2",};stringcardshuffled[ -];intshufflingmachine[ -];intMain () {intN; CIN>>N;  for(inti =1; I < -; i++) {cin>>Shufflingmachine[i]; }     for(inti =0; I < -; i++){        intlocation=Shufflingmachine[i];  for(intj =1; J < N; J + +) { location=Shufflingmachine[location]; } Cardshuffled[location]=Card[i]; }     for(inti =1; I < Wu; i++) {cout<< Cardshuffled[i] <<" "; } cout<< cardshuffled[ Wu];}

Shuffling Machine (20)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.