HzuCZN


私信TA

用户名:0309

访问量:8153

签 名:

等  级
排  名 100
经  验 8364
参赛次数 6
文章发表 12
年  龄 0
在职情况 学生
学  校 贺州学院
专  业 软件工程

  自我简介:

算法极差,要哭了0.0.。。。。。。


解题思路:

注意事项:



参考代码:

#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
string str[1000];
char s[105];
int l;
int cmp(string a,string b)
{
 return a.size()<b.size() ;
}
int main()
{
 int n;
 while(cin>>n){
  getchar();
  l=1;
  for(int i=1;i<=n;i++){
   memset(s,0,sizeof(s));
   gets(s);
   if(strcmp(s,"stop")!=0){
    str[l++]=s;
   }else{
    break;
   }
  // cout<<"**"<<s<<endl;;
  }
  sort(str+1,str+l,cmp);
  for(int i=1;i<l;i++){
   cout<<str[i]<<endl;
  }
 // cout<<"*****"<<endl;
 
 }
 return 0;
}


 

0.0分

1 人评分

  评论区