Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. // Lab4
  2. // V2.1
  3.  
  4. #include <stdio.h>
  5. #include <conio.h>
  6. #include <iostream>
  7.  
  8. int main()
  9. {
  10.     char s[100];
  11.     int i, j, count = 0;
  12.  
  13.     puts("Input string:");
  14.  
  15.     // gets(s);
  16.     std::cin.getline(s, 100);
  17.  
  18.     for (i = 0; s[i] != '\0'; i++)
  19.     {
  20.         if (s[i] == 'A' || s[i] == 'B')
  21.         {
  22.             ++count;
  23.         }
  24.     }
  25.  
  26.     for (i = 1; s[i] != '\0'; i++)
  27.     {
  28.         if (s[i] == 'S' && (s[i - 1] == '.' || s[i - 1] == ';'))
  29.         {
  30.             for (j = i; s[j] != '\0'; j++)
  31.             {
  32.                 s[j] = s[j + 1];
  33.             }
  34.             i--;
  35.         }
  36.     }
  37.  
  38.     puts("\nOutput string: ");
  39.     puts(s);
  40.  
  41.     printf("\nCount A and B: %d", count);
  42.  
  43.     getch();
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement