提交时间:2023-08-22 21:16:26

运行 ID: 99486

#include <bits/stdc++.h> using namespace std; string arr[105]; int main() { string a; getline(cin,a); string s = ""; int cnt = 0; for(int i = 0;i<a.size();i++){ if(i==a.size()-1){ if(s=="") continue; else arr[cnt++] = s; } else if(a[i]>='A'&&a[i]<='Z'||a[i]>='a'&&a[i]<='z'){ s+=a[i]; } else { if(s=="") continue; arr[cnt++] = s; s = ""; } } cout<<cnt<<endl; for(int i = 0;i<cnt;i++){ for(int j = i+1;j<cnt;j++){ if(a[i]<=a[j]) { swap(a[i],a[j]); } } } for(int i = 0;i<cnt;i++) cout<<arr[i]<<endl; return 0; }