Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
75839 | 冯诚阳 | 字符串排序 | C++ | Accepted | 0 MS | 272 KB | 665 | 2024-05-30 19:37:06 |
#include<iostream> #include<string> using namespace std; int main() { int n,b[101]={1},s=1; cin>>n; string str[n],t; int i,j; for (i = 0; i < n; i++) cin >> str[i]; for(i=0;i<n-1;i++) for(j=0;j<n-1-i;j++) if (str[j].size() > str[j + 1].size()) { t = str[j]; str[j] = str[j + 1]; str[j + 1] = t; } for(i=0;i<n-1;i++) for(j=0;j<n-1-i;j++) if (str[j].size()==str[j + 1].size()&&str[j]>str[j+1]) { t = str[j]; str[j] = str[j + 1]; str[j + 1] = t; } for (i=n-1; i>=0; i--) cout<<str[i].size()<<" "<<str[i]<<endl; return 0; }