人生第一次c++,感觉很舒服~~
代码如下:
#include<iostream>
#include<cstring>
#include<sstream>
#include<algorithm>
#include<vector>
using namespace std;
const int MAX = 1000;
int main() {
int i = 0, j = 0, num[MAX];
string line;
vector<string>serie[MAX];
while (getline(cin, line)) {
char tmp;
stringstream ss(line);
while (ss >> tmp) {
if (tmp == ' ') {
num[i]++;
}
}
serie[j++].push_back(line);
i++;
}
sort(num, num + i);
i = num[0];
vector<string>::iterator it = serie[j].begin();
advance(it, i);
while (j-- > 0) {
serie[j].erase(serie[j].begin(), it);
for (auto&& k : serie[j])
cout << k << "
" << endl;
}
/*for (vector<string>::iterator itt = serie[j].begin(); itt < serie->end(); itt++) {
cout << *itt << "
" << endl;
}*/
return 0;
}