Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Da se odredi kolku pati se povtoruva sekoj znak vo nekoja tekstualna niza.
- #include <iostream>
- using namespace std;
- int main()
- {
- char text[500], checked[500];
- int checked_n = 0;
- cout << "Vnesi tekst: ";
- cin.getline(text, 500);
- cout << endl;
- for (int i = 0; text[i] != '\0'; ++i)
- {
- if (text[i] == ' ') continue;
- bool is_checked = false;
- for (int j = 0; text[j] != '\0'; ++j)
- {
- if (text[i] == checked[j])
- {
- is_checked = true;
- }
- }
- if (is_checked) continue;
- char checking = text[i];
- int n = 0;
- checked[checked_n++] = checking;
- for (int j = 0; text[j] != '\0'; ++j)
- {
- if (text[j] == checking) n++;
- }
- cout << "Znakot \"" << checking << "\" se povtoruva " << n << " pati." << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment