简单cpp模拟
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,k;
cin>> n >> k;
int count = 0;
for(int i = 0; i<n; i++){
string c;
cin >> c;
if (c.length() + count > k){
cout << endl << c << ' ';
count = c.length();
}
else {
count += c.length();
cout<< c<< ' ';
}
}
return 0;
}