fork download
  1. #include<iostream>
  2. #include<string.h>
  3. using namespace std;
  4.  
  5. bool isMatching(char *str, char *reg, int n, int m, int i, int j) {
  6. cout<<"FD "<<i<<" "<<str[i]<<" "<<j<<" "<<reg[j]<<endl;
  7. if(i==n&&j==m) return true;
  8. if(i>=n||j>=m) return false;
  9. if(reg[j]<'a'||reg[j]>'z') return false;
  10. if(j+1>=m&&reg[j]==str[i]) return true;
  11. if(j+1>=m) return false;
  12. if(reg[j+1]=='?') {
  13. //0 case
  14. if(isMatching(str, reg, n, m, i, j+2)) return true;
  15. //1 case
  16. if(reg[j]==str[i]) return isMatching(str, reg, n, m, i+1, j+2);
  17. return false;
  18. }
  19. if(reg[j+1]=='*') {
  20. //0 case
  21. if(isMatching(str, reg, n, m, i, j+2)) return true;
  22. while(i<n&&str[i]==reg[j]) {
  23. cout<<i<<" "<<j<<" "<<str[i]<<" "<<reg[j]<<endl;
  24. if(isMatching(str, reg, n, m, ++1, j+2)) return true;
  25. cout<<i<<" "<<j<<" "<<str[i]<<" "<<reg[j]<<endl;
  26. }
  27. return false;
  28. }
  29. if(reg[j]==str[i]) return isMatching(str, reg, n, m, i+1, j+1);
  30. return false;
  31. }
  32.  
  33. int main() {
  34. char reg[10], str[256];
  35. scanf("%s%s",str, reg);
  36. cout<<isMatching(str, reg, strlen(str), strlen(reg), 0, 0)<<endl;
  37. return 0;
  38. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
kaaapil
ka*pil
compilation info
prog.cpp: In function ‘bool isMatching(char*, char*, int, int, int, int)’:
prog.cpp:24: error: lvalue required as increment operand
prog.cpp: In function ‘int main()’:
prog.cpp:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
stdout
Standard output is empty