[华为刷题]分解字符串,string解法
来源:互联网 发布:网络购彩平台贴吧 编辑:程序博客网 时间:2024/06/07 08:12
#include <iostream>#include <vector>#include<string>#include<algorithm>using namespace std;int main() {string s[2];vector<string> result;getline(cin,s[0]);getline(cin, s[1]);for (int i = 0; i < 2; i++){if (s[i].size() <=8){int leng = s[i].size();for (int j = leng; j< 8; j++){s[i].insert(leng,1,'0');}result.push_back(s[i]);}else{int time = s[i].size() / 8;int other = s[i].size() % 8;string temp;for (int m = 0; m < time; m++){temp.assign(s[i].begin() + m * 8, s[i].begin() + m * 8 + 8);result.push_back(temp);}if (other != 0){temp.assign(s[i].begin() + time * 8, s[i].end());int ll = temp.size();temp.insert(ll, 8 - other, '0');result.push_back(temp);}}}for (int i = 0; i < result.size(); i++){cout << result[i] << endl;}return 0;}
阅读全文
0 0
- [华为刷题]分解字符串,string解法
- 华为oj【分解字符串】
- 【华为】分解字符串
- [华为机试练习题]3.分解字符串
- 华为上机试题2(字符串分解)
- 【c++】【2015华为笔试】分解字符串
- C++利用string和vector分解字符串
- 华为机试题(替换字符串)——Java解法
- 008华为机试分解字符串,M,N问题
- 将一个string字符串变量分解为字符输出
- 将String中的字符串分解成单个的单词
- 【华为OJ】字符串解析运用-将字符串分解为多个整数,求各整数之和
- 分解字符串
- 字符串分解
- 分解字符串
- 分解字符串
- 分解字符串
- 分解字符串
- 事务笔记
- 1001. A+B Format (20)
- GitHub 博客自定义域名配置(阿里)
- 4岁开始升牛,9岁死----分支简单算法
- Java线程状态
- [华为刷题]分解字符串,string解法
- 在 Xshell 中 使用 hbase shell 进入后 无法删除
- 几何图形的绘制
- HDU
- 【数据结构】最大子序列问题
- 【Linux/Ubuntu学习】E: 无法获得锁 /var/lib/dpkg/lock – open (11: 资源暂时不可用) E: 无法锁定管理目录 解决办法
- win7 VS2008 编译luabind-0.9.1 动态库 静态库
- session-path
- Java多线程