Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. void countDistinct(char symbols[], int i, int j) {
  5.  
  6. int count = 0;
  7. bool different = false;
  8. for (int k = i; k <= j; k++)
  9. {
  10. for (int p = i; p <= j; p++)
  11. {
  12.  
  13. if (symbols[k] != symbols[p]) {
  14. different = true;
  15. }
  16.  
  17. if (different == true) {
  18. count++;
  19. different = false;
  20. }
  21. }
  22.  
  23. cout<<count;
  24. }
  25. int main() {
  26. char symbols[]= { 'n', 'a', 'b', 'a', 'b', 'a', 't', 'i', 'h', 'v', 'u', 'r', '4', 'i', 'l', 'o', 't', 'o' };
  27.  
  28. int i, j;
  29. cin >> i >> j;
  30.  
  31. if (j < i)
  32. std::cout << "Wrong input!" << std::endl;
  33. //if (i == j)
  34. // std::cout << 1 << std::endl;
  35.  
  36. countDistinct(symbols, i, j);
  37.  
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement