Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5. bool descentrate(char imp[],char par[]);
  6. int main()
  7. {
  8. char a[256];
  9. char *c,*b[256];
  10.  
  11. int n=0;
  12. cin.getline(a,256);
  13. c=strtok(a," ");
  14. while(c)
  15. {
  16. b[++n]=c;
  17. c=strtok(0," ");
  18. }
  19. for(int i=1;i<n;++i)
  20. for(int j=i+1;j<=n;++j)
  21. {
  22. if(strlen(b[i])-strlen(b[j])==1&&strlen(b[i])%2==0)
  23. if(descentrate(b[j],b[i]))
  24. {
  25. cout<<"DA";
  26. return 0;
  27. }
  28.  
  29. if(strlen(b[j])-strlen(b[i])==1&&strlen(b[j])%2==0)
  30. if(descentrate(b[i],b[j]))
  31. {
  32. cout<<"DA";
  33. return 0;
  34. }
  35. }
  36. cout<<"NU";
  37. return 0;
  38. }
  39. bool descentrate(char imp[],char par[])
  40. {
  41. int n=strlen(imp)-1;
  42. for(int i=0;i<=n/2;++i)
  43. if(imp[i]!=par[i])
  44. return false;
  45. if(par[n/2]!=par[n/2+1])
  46. return false;
  47. for(int i=n/2+1;i<n;++i)
  48. if(imp[i]!=par[i+1])
  49. return false;
  50. return true;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement