fork(11) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5.  
  6. string Helper(string sr, int maxLength) {
  7. if (sr.size()!=0) {
  8. return sr;
  9. }
  10. if (sr.size() == maxLength) {
  11. return "";
  12. }
  13. for (char c = 'a'; c <= 'z'; c++) {
  14. string password = Helper (sr + c, maxLength);
  15. if (password != "") {
  16. return password;
  17. }
  18. // Also check uppercase
  19. char upperC = toupper(c);
  20. password = Helper (sr + upperC, maxLength);
  21. if (password != "") {
  22. return password;
  23. }
  24. }
  25. return "";
  26. }
  27.  
  28. void solve(int maxLength) {
  29. if (maxLength < 0) {
  30. throw maxLength;
  31. }
  32. return Helper("", maxLength);
  33. }
  34. int main()
  35. {
  36. int t;cin>>t;
  37. while(t--){
  38. string s;cin>>s;
  39. solve(s);
  40.  
  41. }
  42. return 0;
  43. }
Compilation error #stdin compilation error #stdout 0.01s 5440KB
stdin
3
b02w
b055
3245
compilation info
prog.cpp: In function ‘void solve(int)’:
prog.cpp:32:30: error: return-statement with a value, in function returning ‘void’ [-fpermissive]
   return Helper("", maxLength);
                              ^
prog.cpp: In function ‘int main()’:
prog.cpp:39:9: error: cannot convert ‘std::__cxx11::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘int’
   solve(s);
         ^
prog.cpp:28:16: note:   initializing argument 1 of ‘void solve(int)’
 void solve(int maxLength) {
            ~~~~^~~~~~~~~
stdout
Standard output is empty