Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- int main()
- {
- int h, w, n; //вводимые числа
- int a = 0, b = 1, c = 1; //счетчики
- cin >> h >> w >> n;
- string trash;
- getline(cin, trash);
- vector<string> words;
- for (int i = 0; i < n; i++)
- {
- string word;
- getline(cin, word);
- if (a + word.size() >w)
- {
- b += 1;
- a = 0;
- }
- a += word.size()+1;
- if(b > h)
- {
- c += 1;
- b = 1;
- }
- }
- cout << c;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement