返回列表 發帖
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. string s="0000";
  4. queue<char> q;
  5. int x;
  6. int main()
  7. {
  8.     for(int i=0; i<10; i++)
  9.     {
  10.         if(i<4)
  11.         {
  12.             cin>>s[i];
  13.             q.push(s[i]);
  14.         }else
  15.         {
  16.             char b, c;
  17.             cin>>b;
  18.             if(s.find(b) == -1)
  19.             {
  20.                 q.push(b);
  21.                 c=q.front();
  22.                 q.pop();
  23.                 x=s.find(c);
  24.                 s[x]=b;
  25.             }
  26.         }
  27.         cout<<s[0]<<" "<<s[1]<<" "<<s[2]<<" "<<s[3]<<" "<<endl;
  28.     }
  29.     return 0;
  30. }
複製代碼

TOP

返回列表