Advertisement
GarikK

WhileToUnderstand

Feb 21st, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. // HomeWork_while.cpp
  2. //
  3.  
  4. #include <iostream>
  5. #include <string>
  6. using namespace std;
  7. int main()
  8. {
  9.     string block1;
  10.     char stopSymbol;
  11.     char symbolFind;
  12.     cin >> block1 >> stopSymbol >> symbolFind;
  13.     int blockNumber = 0;
  14.     int amount = 0;
  15.     int i = 0;
  16.  
  17.     while (i < block1.length())
  18.     {
  19.         while (block1[i] != stopSymbol)
  20.         {
  21.             char currentSymbol = block1[i];
  22.             if (currentSymbol == symbolFind)
  23.             {
  24.                 amount++;
  25.             }
  26.             i++;
  27.             if (i >= block1.length()) break;
  28.         }
  29.  
  30.         cout << "Block " << blockNumber << " " << symbolFind << " quantity - " << amount << endl;
  31.         amount = 0;
  32.         blockNumber++;
  33.         i++;
  34.     }  
  35.     cout << "That\' all" << endl;
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement