Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define endl "\n"
- using namespace std;
- string s1,input;
- vector<string>s;
- vector<string>ans;
- void dfs(int index,string temp)
- {
- if(index==s1.size())
- {
- ans.push_back(temp);
- return;
- }
- char j;
- if(s1[index]=='0')
- {
- for(j='0';j<='9';j++)
- {
- string s2 = temp;
- s2+=j;
- dfs(index+1,s2);
- }
- }
- else if(s1[index]=='#')
- {
- for(auto idx : s)
- {
- string s2 = temp;
- s2+=idx;
- dfs(index+1,s2);
- }
- }
- }
- int main()
- {
- int n,m,i;
- while(scanf("%d",&n)==1)
- {
- for(i=1; i<=n; i++)
- {
- cin>>input;
- s.push_back(input);
- }
- scanf("%d",&m);
- while(m--)
- {
- cin>>s1;
- string _empty="";
- dfs(0,_empty);
- }
- printf("--\n");
- for(auto loop : ans)
- {
- cout<<loop<<endl;
- }
- ans.clear();
- s.clear();
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment