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