题目大意:小A有一些烦恼,现在要求你去给他解决一下。
思路:语法基础题。
CODE:
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#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;
}