Advertisement
Balto_

Untitled

Apr 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.10 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <stdio.h>
  4. #include <conio.h>
  5.  
  6. using namespace std;
  7.  
  8. const int N = 1000;
  9. int kl;
  10. int RemoveCharacter(char *str...) {
  11.     char *tmp = new char[N];
  12.     char punctuation_marks[] = ".,!?;:'()\"";
  13.     int count = 0, temp = 0, size = strlen(str);
  14.     bool flag = true;
  15.     int masscount[10];
  16.     cout << "List of banned characters ";
  17.     for (int i = 0; i<strlen(punctuation_marks); i++) cout << punctuation_marks[i] << " ";
  18.     cout << "\nBanned characters in your text: ";
  19.     for (int i = 0; i<strlen(str); i++)
  20.     {
  21.         for (int j = 0; j<sizeof(punctuation_marks); j++)
  22.         {
  23.             if (str[i] == punctuation_marks[j])
  24.             {
  25.                 count++;
  26.                 for (int k = 0; k<strlen(tmp); k++)
  27.                 {
  28.                     if (str[i] == tmp[k]) flag = false;
  29.                 }
  30.                 if (flag == true) cout << punctuation_marks[j] << " ";
  31.                 tmp[temp] = punctuation_marks[j];
  32.                 temp++;
  33.             }
  34.             flag = true;
  35.         }
  36.  
  37.     }
  38.     cout << "\n";
  39.     cout << "Number of banned character " << count;
  40.     if (count == 0) cout << "\nnot found.\n";
  41.     for (int i = 0; i<strlen(str); i++)
  42.     {
  43.         for (int j = 0; j<strlen(punctuation_marks); j++)
  44.         {
  45.             if (str[i] == punctuation_marks[j])
  46.             {
  47.                 for (int k = i; k<size; k++) str[k] = str[k + 1];
  48.                 size--;
  49.             }
  50.         }
  51.     }
  52.     for (int i = 0; i<strlen(str); i++)
  53.     {
  54.         for (int j = 0; j<strlen(tmp); j++)
  55.         {
  56.             if (str[i] == tmp[j])
  57.             {
  58.                 for (int k = i; k<size; k++) str[k] = str[k + 1];
  59.                 size--;
  60.             }
  61.         }
  62.     }
  63.  
  64.     //Выводим, если есть шо
  65.     size = strlen(str);
  66.     if (size != 0)
  67.     {
  68.         cout << "\nCorrected text: ";
  69.         puts(str);
  70.     }
  71.     cout << "\n";
  72.     return count;
  73. }
  74.  
  75.  
  76. void main()
  77. {
  78.     system("chcp 1251");
  79.     int kl = 0;
  80.     cout << "Enter the number of rows: ";
  81.     cin >> kl;
  82.     int iDelNum = 0, iRow = 0;
  83.     for (int i = 0; i < kl; i++) {
  84.         char *str = new char[N];
  85.         getchar();
  86.         cout << "Enter row: ";
  87.         gets_s(str, N);
  88.         cout << "Your row: ";
  89.         puts(str);
  90.         int iCount = RemoveCharacter(str, kl);
  91.         if (iCount > iDelNum) {
  92.             iDelNum = iCount;
  93.             iRow = i;
  94.         }
  95.     }
  96.  
  97.     cout << "Most deleted symbols row[" << iRow + 1 << "]: " << iDelNum << endl;
  98.     getchar();
  99.     getchar();
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement