Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <iomanip>
- using namespace std;
- //Для каждого символа заданного текста указать, сколько раз он встречается в тексте.
- //Удалить символы, которые встречаются более одного раза.
- int main() {
- const int str_len = 100000;
- char str[str_len] = "";
- while (true) {
- cout << "Enter text " << endl;
- cin.getline(str, str_len);
- cout << str << endl;
- int len = 1;
- for (int i = 0; str[i]; len++, i++);
- for (int i = 0; i < len; i++) {
- if (!str[i]) {
- continue;
- }
- char ch = str[i];
- int ch_count = 0;
- for (int j = 0; j < len; j++) {
- if (str[j] == ch) {
- ch_count++;
- if (ch_count > 1) {
- str[j] = '\0';
- str[i] = '\0';
- }
- }
- }
- cout << ch << " - " << ch_count << endl;
- }
- for (int i = 0; i < len; i++) {
- if (!str[i]) {
- int j;
- for (j = i + 1; j < len && !str[j]; j++);
- str[i] = str[j];
- str[j] = '\0';
- }
- }
- cout << str << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement