文章

5

粉丝

136

获赞

4

访问

39.0k

头像
C++用sort排序
P1012 贵州大学机试题
发布于2021年2月17日 14:05
阅读数 9.4k

#include <iostream>
#include <algorithm>
using namespace std;
bool cmp(char a,char b)
{
    if(isdigit(a)==0&&isdigit(b)!=0) return 1;
    else return 0;
}

int main()
{
string s;
cin>>s;
sort(s.begin(),s.end(),cmp);
cout<<s;
return 0;
}

登录查看完整内容


登录后发布评论

1 条评论
fancy
2022年3月19日 17:03

#include <iostream>
#include <algorithm>
using namespace std;
bool cmp(char a,char b)
{
    if(isdigit(a)==0&&isdigit(b)!=0) return 1;
    else return 0;
}

int main()
{
string s;
cin>>s;
sort(s.begin(),s.end(),cmp);
cout<<s;
return 0;
}

 

赞(0)