Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void countDistinct(char symbols[], int i, int j) {
- int count = 0;
- bool different = false;
- for (int k = i; k <= j; k++)
- {
- for (int p = i; p <= j; p++)
- {
- if (symbols[k] != symbols[p]) {
- different = true;
- }
- if (different == true) {
- count++;
- different = false;
- }
- }
- cout<<count;
- }
- int main() {
- char symbols[]= { 'n', 'a', 'b', 'a', 'b', 'a', 't', 'i', 'h', 'v', 'u', 'r', '4', 'i', 'l', 'o', 't', 'o' };
- int i, j;
- cin >> i >> j;
- if (j < i)
- std::cout << "Wrong input!" << std::endl;
- //if (i == j)
- // std::cout << 1 << std::endl;
- countDistinct(symbols, i, j);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement