Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
75844 冯诚阳 字符串排序 C++ Wrong Answer 1 MS 276 KB 665 2024-05-30 19:53:10

Tests(0/2):


Code:

#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; }


Run Info:

------Input------
4 1 321 21 3 25
------Answer-----
4 21 3 3 321 2 25 1 1
------Your output-----
3 321 2 21 1 3 1 1