fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. bool check(string str){
  4.  
  5. for(auto c:str){
  6. if(c=='?')
  7. return false;
  8. }
  9. return true;
  10. }
  11. void go(string str,int pos){
  12.  
  13. if(check(str)){
  14. cout<<str<<endl;
  15. return;
  16. }
  17. if(str[pos]=='1' || str[pos]=='0')
  18. go(str,pos+1);
  19. else if(str[pos]=='?'){
  20. str[pos]='0';
  21. go(str,pos+1);
  22. str[pos]='1';
  23. go(str,pos+1);
  24. }
  25. }
  26. int main(){
  27. string str="1??0";
  28. //cin>>str;
  29. go(str,0);
  30. }
Success #stdin #stdout 0s 5444KB
stdin
1??0
stdout
1000
1010
1100
1110