Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int func(string str,string mask)
  4. {
  5. bool has=false;
  6. for (int i=0;i<mask.size();++i)
  7. {
  8. if (mask[i]=='*')
  9. has=true;
  10. }
  11. if (str.size()-mask.size()!=0 && has==false)
  12. {
  13. cout<<"NO"<<endl;
  14. return 0;
  15. }
  16. //if ()
  17. //cout<<str.size()-mask.size()<<endl;
  18. int kol=str.size()-mask.size()+has;
  19. int check=0;
  20. //assert(kol>=0);
  21. if (kol<0)
  22. {
  23. cout<<"NO"<<endl;
  24. return 0;
  25. }
  26. for (int i=0;i<mask.size();++i)
  27. {
  28. if (check>=str.size())
  29. {
  30. cout<<"NO"<<endl;
  31. return 0;
  32. }
  33. // cout<<mask[i]<<" "<<str[check]<<endl;
  34. bool z=false;
  35. if (mask[i]=='*')
  36. {
  37. z=true;
  38. }
  39. else if (mask[i]=='?' || mask[i]==str[check])
  40. {
  41.  
  42. }
  43. else if (mask[i]!=str[check] && mask[i]!='*')
  44. {
  45. cout<<"NO"<<endl;
  46. return 0;
  47.  
  48. }
  49. check++;
  50. if (z)
  51. check+=kol-1;
  52. }
  53. cout<<"YES"<<endl;
  54. return 0;
  55. }
  56. int main()
  57. {
  58. //freopen("input.txt","r",stdin);
  59. string mask;
  60. cin>>mask;
  61. for (int i=0;i<5;++i)
  62. {
  63. string str;
  64. cin>>str;
  65. func(str,mask);
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement