Advertisement
srtgguy

Untitled

May 23rd, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int h, w, n;  //вводимые числа
  10.     int a = 0, b = 1, c = 1;  //счетчики
  11.     cin >> h >> w >> n;
  12.     string trash;
  13.     getline(cin, trash);
  14.     vector<string> words;
  15.     for (int i = 0; i < n; i++)
  16.     {
  17.         string word;
  18.         getline(cin, word);
  19.         if (a + word.size() >w)
  20.         {
  21.             b += 1;
  22.             a = 0;
  23.         }
  24.         a += word.size()+1;
  25.         if(b > h)
  26.         {
  27.             c += 1;
  28.             b = 1;
  29.         }
  30.     }
  31.     cout << c;
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement