文章

25

粉丝

0

获赞

104

访问

3.3k

头像
字符串排序2 题解:
P1255 北京大学机试题
发布于2026年3月12日 10:56
阅读数 143

#include <iostream>
#include <string>
#include <algorithm>
#include<ctype.h>
#include<map>
#include<vector>
#include<sstream>
using namespace std;
bool cmp(char a,char b){
    if(abs(a-b)==32){
        return 0;
    }
    else{
        char lowa=tolower(a),lowb=tolower(b);
        return lowa<lowb;
    }
}
int main() {
    string str1,str2;
    while(getline(cin,str1)){
        for(char i:str1){
            if((i>='a'&&i<='z')||(i>='A'&&i<='Z')){
                str2+=i;
            }
        }
        stable_sort(str2.begin(),str2.end(),cmp);
        int ind=...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发