#include <bits/stdc++.h>
using namespace std;
int main() {
// 南方1,北方2,分不清3
int north_south = 1;
//男1 女2
int gender = 1;
//名字长度2~7的自然数
int name_length = 2;
//随机数生成器
random_device rd;
mt19937 gen(rd());
uniform_int_distribution<> dis(1, 4); //用于生成随机插入位置
cout << "洗牌前" << endl;
//初始化牌,随机自己喜欢的4个牌
vector<int> cards = {2, 7, 6, 5, 2, 7, 6, 5};
for(int card : cards) {
cout << card << " ";
}
cout << endl;
// 将队头的name_length插入队尾
for (int i = 0; i < name_length; ++i) {
int card = cards[0];
cards.erase(cards.begin());
cards.push_back(card);
}
cout << "名字插入队尾后" << endl;
for (int card : cards) {
cout << card << " ";
}
cout << endl;
// 将对头的三个元素插入中间
vector<int> top_three(cards.begin(), cards.begin() + 3);
vector<int> last_five(cards.begin() + 3, cards.end());
int location = dis(gen);
cards = last_five;
cards.insert(cards.begin() + location, top_three.begin(), top_three.end());
cout << "前三张牌插入中间后" << endl;
for (int card : cards) {
cout << card << " ";
}
cout << endl;
// 屁股下的牌
int under_butt = cards.front();
cout << "藏起来的牌:" << under_butt << endl;
cards.erase(cards.begin());
//根据南北方和性别调整牌
vector<int> top_cards(cards.begin(), cards.begin() + north_south);
vector<int> last_cards(cards.begin() + north_south, cards.end());
location = dis(gen);
cards = last_cards;
cards.insert(cards.begin() + location, top_cards.begin(), top_cards.end());
cout << "(南北方牌)插入中间后:" << endl;
for (int card : cards) {
cout << card << " ";
}
cout << endl;
for (int i = 0; i < gender; ++i) {
cards.erase(cards.begin());
}
cout << "去掉性别对应的牌后:" << endl;
for (int card : cards) {
cout << card << " ";
}
cout << endl;
cout << "见证奇迹的时刻……" << endl;
// 见证奇迹的时刻
for (int i = 0; i < 7; ++i) {
int card = cards.front();
cards.erase(cards.begin());
cards.push_back(card);
}
for (int card : cards) {
cout << card << " ";
}
cout << endl;
cout << "好运留下来,烦恼丢出去" << endl;
while (cards.size() > 1) {
//好运留下来
int card = cards.front();
cards.erase(cards.begin());
cards.push_back(card);
//烦恼丢出去
cards.erase(cards.begin());
for (int card : cards) {
cout << card << " ";
}
cout << endl;
}
cout << "最终留下的牌:" << endl;
for (int card : cards) {
cout << card << " ";
}
cout << endl;
return 0;
}
2024年春晚刘谦魔术揭秘!!!!!
于 2024-02-12 09:24:53 首次发布