返回列表 發帖
本帖最後由 高鋐鈞 於 2024-9-25 18:46 編輯
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. queue<char> q;
  4. int main()
  5. {
  6.     string s="0000";
  7.     for(int i=0; i<10; i++)
  8.     {
  9.         if(i<4)
  10.         {
  11.             cin>>s[i];
  12.             q.push(s[i]);
  13.         }else
  14.         {
  15.             char in, ot;
  16.             cin>>in;
  17.             if(s.find(in)==-1)
  18.             {
  19.                 q.push(in);
  20.                 ot=q.front();
  21.                 q.pop();
  22.                 int x=s.find(ot);
  23.                 s[x]=in;
  24.             }
  25.         }
  26.         printf("%c %c %c %c \n", s[0], s[1], s[2], s[3]);
  27.     }
  28.     return 0;
  29. }
複製代碼

TOP

返回列表