返回列表 發帖
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. string s="0000";
  4. queue<int> 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.        }else{
  14.        char in, ot;
  15.        cin>>in;
  16.        if(s.find(in)==-1){
  17.             q.push(in);
  18.        ot=q.front();
  19.        q.pop();
  20.        int idx=s.find(ot);
  21.        s[idx]=in;
  22.        }
  23.        }
  24.         printf("%c %c %c %c \n", s[0], s[1], s[2], s[3]);
  25.    }

  26.     return 0;
  27. }
複製代碼

TOP

返回列表