fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int isThere(char st[],char nd)
  6. {
  7. int i=0;
  8. while(st[i]!=0)
  9. {
  10. i++;
  11. }
  12. for(int k=0;k<i;k++)
  13. {
  14. if(nd==st[k])
  15. {
  16. return k;
  17. }
  18. }
  19. return -1;
  20. }
  21. bool check(char nd[],int p)
  22. {
  23. int x=0;
  24. for(int i=0;i<p;i++)
  25. {
  26. if(nd[i]=='1')
  27. {
  28. x++;
  29. if(x==p)
  30. {
  31. return true;
  32. }
  33. }
  34. }
  35. return false;
  36. }
  37. int main()
  38. {
  39. char st[20],nd[20];
  40. cin.getline(st,20);cin.getline(nd,20);
  41. int p=0;int c=0;
  42. while(nd[p]!=0)
  43. {
  44. p++;
  45. }
  46. for(c;c<p;c++)
  47. {
  48. if(isThere(st,nd[c])!=-1)
  49. {
  50. st[isThere(st,nd[c])]='0';
  51. nd[c]='1';
  52. }
  53. else
  54. {
  55. nd[c]='0';
  56. }
  57. }
  58. cout<<check(nd,p);
  59. return 0;
  60. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
Standard output is empty