Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Lab4
- // V2.1
- #include <stdio.h>
- #include <conio.h>
- #include <iostream>
- int main()
- {
- char s[100];
- int i, j, count = 0;
- puts("Input string:");
- // gets(s);
- std::cin.getline(s, 100);
- for (i = 0; s[i] != '\0'; i++)
- {
- if (s[i] == 'A' || s[i] == 'B')
- {
- ++count;
- }
- }
- for (i = 1; s[i] != '\0'; i++)
- {
- if (s[i] == 'S' && (s[i - 1] == '.' || s[i - 1] == ';'))
- {
- for (j = i; s[j] != '\0'; j++)
- {
- s[j] = s[j + 1];
- }
- i--;
- }
- }
- puts("\nOutput string: ");
- puts(s);
- printf("\nCount A and B: %d", count);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement