Advertisement
Guest User

Untitled

a guest
Mar 4th, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool da(string a, string b){
  5. int j_old=0;
  6. int br=0;
  7. for(int i=0;i<a.size();i++){
  8. for(int j=j_old;j<b.size();j++){
  9. if(a[i]==b[j]){
  10. a[i]=' ';
  11. b[j]=' ';
  12. j_old=j;
  13. br++;
  14. break;
  15. }
  16. }
  17. }
  18. if(br==a.size())
  19. return true;
  20. else
  21. return false;
  22. }
  23. int main() {
  24.  
  25.  
  26. int n;
  27. cin>>n;
  28. while (n--){
  29. string s,t;
  30. cin>>s>>t;
  31. if (da(s,t)==true) cout <<"DA"<<" ";
  32. else cout << "NE"<<" ";
  33.  
  34. }
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement