Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 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 = 1; s[i] != '\0'; i++)
  19.     {
  20.         if (s[i] == 'A' || s[i] == 'B')
  21.         {
  22.             ++count;
  23.         }
  24.         if (s[i] == 'S' && (s[i - 1] == '.' || s[i - 1] == ';'))
  25.         {
  26.             for (j = i; s[j] != '\0'; j++)
  27.             {
  28.                 s[j] = s[j + 1];
  29.             }
  30.             i--;
  31.         }
  32.     }
  33.  
  34.     puts("\nOutput string: ");
  35.     puts(s);
  36.  
  37.     printf("\nCount A and B: %d", count);
  38.  
  39.     getch();
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement