Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. bool matchingValuesTogether(const string array[], int n)
  7. {
  8. bool result = true;
  9. if (n < 1)
  10. {
  11. return false;
  12. }
  13. else
  14. {
  15. for (int i = 0; i < n - 1; i++)
  16. {
  17. if (array[i] != array[i + 1])
  18. {
  19. for (int c = 0; c < i; i++)
  20. {
  21. if (array[i + 1] == array[c])
  22. {
  23. result = false;
  24. }
  25. }
  26. }
  27. }
  28. }
  29. return(result);
  30. }
  31.  
  32.  
  33. int main()
  34. {
  35.  
  36.  
  37. string b[5] = { "dog", "dog", "cat", "fish", "cat" };
  38.  
  39.  
  40.  
  41. string c[5] = { "dog", "dog", "cat", "cat", "fish" };
  42. bool me = matchingValuesTogether(c, 5);
  43.  
  44.  
  45. cout << me << endl;
  46.  
  47.  
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement