題目大意:小A有一些煩惱,現在要求你去給他解決一下。
思路:語法基礎題。
CODE:
#include#include #include #include #include #define MAX 1010 using namespace std; int total,m; string ans[MAX],name; int cnt[MAX]; int main() { cin >> total; for(int num,i = 1; i <= total; ++i) { cin >> num >> name; ans[0] += name; m = max(m,num); memset(cnt,0,sizeof(cnt)); for(int j = 1; j <= num; ++j) { string temp; cin >> temp; ans[j] += temp; for(string::iterator it = temp.begin(); it != temp.end(); ++it) cnt[j] += *it == ','; } int _max = *max_element(cnt + 1,cnt + num + 1); for(int j = 0; j < MAX; ++j) for(int k = cnt[j]; k <= (i == total ? _max - 1:_max); ++k) ans[j] += ','; } for(int i = 0; i <= m; ++i) cout << ans[i] << endl; return 0; }