- #include<bits/stdc++.h>
- using namespace std;
- string s="0000";
- queue <char> q;
- int main()
- {
- for(int i=0;i<10;i++)
- {
- if(i<4)
- {
- cin>>s[i];
- q.push(s[i]);
- }
- else
- {
- char in,ot;
- cin>>in;
- if(s.find(in)==-1)
- {
- q.push(in);
- ot=q.front();
- q.pop();
- int idx=s.find(ot);
- s[idx]=in;
- }
- }
- printf("%c %c %c %c \n",s[0],s[1],s[2],s[3]);
- }
- return 0;
- }
複製代碼 |