字符串大小写移动位置
来源:互联网 发布:奥拉朱旺数据 编辑:程序博客网 时间:2024/05/17 01:44
腾讯 实习生题目
小Q最近遇到了一个难题:把一个字符串的大写字母放到字符串的后面,各个字符的相对位置不变,且不能申请额外的空间。
你能帮帮小Q吗?
看到众多答案中 这是我最服的答案 没有之一!
#include <iostream>#include <string.h>using namespace std;int main(){ string s; while(cin >> s){ if(s.length() >= 1 && s.length() <= 1000){ for(int i = 0; i < s.length(); i++) if(s[i] >= 'a' && s[i] <= 'z') cout << s[i]; for(int i = 0; i < s.length(); i++) if(s[i] <= 'Z' && s[i] >= 'A') cout << s[i]; cout << endl;//开始没写这个老是通不过... } } return 0;}
下面的也比较机智:
#include<iostream> #include<algorithm> using namespace std; bool isLower(charc) { returnc>='a'; } intmain() { string s; while(cin >> s) { stable_partition(s.begin(),s.end(),isLower); cout << s << endl; } }
0 0
- 字符串大小写移动位置
- 字符串翻转并相应位置对应大小写
- java移动字符串显示位置
- C语言考试题 移动字符串位置
- stripos — 查找字符串首次出现的位置(不区分大小写)
- java字符串中提取相应位置的字符及大小写转换
- 使用boost查找区分大小写查找,查找一个字符串在另外一个字符串的位置,返回索引。
- 字符串大小写转换
- string字符串大小写函数
- string字符串大小写函数
- 字符串转换大小写方法
- 判断字符串的大小写
- c++字符串大小写转换
- c++字符串大小写转换
- delphi 大小写字符串转换
- 字符串大小写格式化
- c++字符串大小写转换
- python 字符串 大小写转换
- 如何让Linux进程在后台运行
- 简单的使用Socket实现数据通信
- wildfly standalone 模式配置成linux 服务
- C#中的弱引用(WeakReference
- QT笔记:数据库总结(三)之SQL模型类-QSqlTableModel模型
- 字符串大小写移动位置
- 【个人作品】在SIP客户端实现服务器端的IVR(互动式语音应答,即语音导航,自动语音话务员)功能
- 基于系统的封装SegmentView类
- $.ajax()方法详解
- Android学习之SD卡写入bitmap位图
- Java监控文件夹或文件的变动
- C++:虚基类
- QT笔记:数据库总结(四)之SQL模型类-QSqlRelationalTableModel模型
- windows利用pip安装python包(numpy为例)