本文主要是介绍【PAT甲级 扑克洗牌】1042 Shuffling Machine (20 分) C++ 全部AC,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
题目
大概是所有题里面最简单的一道题了。10分钟解决。
意思是:根据题目给的顺序洗牌,洗牌n次之后的结果输出。
C++ 题解
#include<iostream>
#include<string>
using namespace std;
int main() {string arr1[] = {"","S1","S2","S3","S4","S5","S6","S7","S8","S9","S10","S11","S12","S13","H1","H2","H3","H4","H5","H6","H7","H8","H9","H10","H11","H12","H13","C1","C2","C3","C4","C5","C6","C7","C8","C9","C10","C11","C12","C13","D1","D2","D3","D4","D5","D6","D7","D8","D9","D10","D11","D12","D13", "J1","J2"};string arr2[55];int repeat;cin >> repeat;int a[55];for (int i = 1; i <= 54; i++) {cin >> a[i];}for (int i = 0; i < repeat; i++) {//arr1重排放入arr2for (int i = 1; i <= 54; i++) {arr2[a[i]] = arr1[i];}//arr2复制到arr1for (int i = 1; i <= 54; i++) {arr1[i] = arr2[i];}}//输出for (int i = 1; i <= 54; i++) {cout << arr2[i];if (i != 54)cout << " ";}system("pause");
}
这篇关于【PAT甲级 扑克洗牌】1042 Shuffling Machine (20 分) C++ 全部AC的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!