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

TOP

  1. aaa
複製代碼

TOP

返回列表