Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <stdio.h>
- #include <conio.h>
- using namespace std;
- const int N = 1000;
- int kl;
- int RemoveCharacter(char *str...) {
- char *tmp = new char[N];
- char punctuation_marks[] = ".,!?;:'()\"";
- int count = 0, temp = 0, size = strlen(str);
- bool flag = true;
- int masscount[10];
- cout << "List of banned characters ";
- for (int i = 0; i<strlen(punctuation_marks); i++) cout << punctuation_marks[i] << " ";
- cout << "\nBanned characters in your text: ";
- for (int i = 0; i<strlen(str); i++)
- {
- for (int j = 0; j<sizeof(punctuation_marks); j++)
- {
- if (str[i] == punctuation_marks[j])
- {
- count++;
- for (int k = 0; k<strlen(tmp); k++)
- {
- if (str[i] == tmp[k]) flag = false;
- }
- if (flag == true) cout << punctuation_marks[j] << " ";
- tmp[temp] = punctuation_marks[j];
- temp++;
- }
- flag = true;
- }
- }
- cout << "\n";
- cout << "Number of banned character " << count;
- if (count == 0) cout << "\nnot found.\n";
- for (int i = 0; i<strlen(str); i++)
- {
- for (int j = 0; j<strlen(punctuation_marks); j++)
- {
- if (str[i] == punctuation_marks[j])
- {
- for (int k = i; k<size; k++) str[k] = str[k + 1];
- size--;
- }
- }
- }
- for (int i = 0; i<strlen(str); i++)
- {
- for (int j = 0; j<strlen(tmp); j++)
- {
- if (str[i] == tmp[j])
- {
- for (int k = i; k<size; k++) str[k] = str[k + 1];
- size--;
- }
- }
- }
- //Выводим, если есть шо
- size = strlen(str);
- if (size != 0)
- {
- cout << "\nCorrected text: ";
- puts(str);
- }
- cout << "\n";
- return count;
- }
- void main()
- {
- system("chcp 1251");
- int kl = 0;
- cout << "Enter the number of rows: ";
- cin >> kl;
- int iDelNum = 0, iRow = 0;
- for (int i = 0; i < kl; i++) {
- char *str = new char[N];
- getchar();
- cout << "Enter row: ";
- gets_s(str, N);
- cout << "Your row: ";
- puts(str);
- int iCount = RemoveCharacter(str, kl);
- if (iCount > iDelNum) {
- iDelNum = iCount;
- iRow = i;
- }
- }
- cout << "Most deleted symbols row[" << iRow + 1 << "]: " << iDelNum << endl;
- getchar();
- getchar();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement