## 解題思路 這題也可以用一個陣列儲存位置對應的卡片,方便執行後面要交換的操作 ```cpp= #include<bits/stdc++.h> using namespace std ; string cards[20] ; int main() { ios::sync_with_stdio(0), cin.tie(0) ; for (int i=0;i<14;i++) cin >> cards[i] ; int n ; cin >> n ; for (int i=0;i<n;i++) { string tmp ; int a, b ; cin >> a >> b ; // 交換 tmp = cards[a] ; cards[a] = cards[b] ; cards[b] = tmp ; } int idx = 0, take ; // 鬼牌在誰手上 for (int i=1;i<=14;i++) { cin >> take ; if (cards[take] == "Joker") idx = i ; } for (int i=0;i<14;i++) cout << cards[i] << ' ' ; cout << '\n' ; cout << idx ; return 0 ; } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up