字符串分割
来源:互联网 发布:软件招商加盟政策 编辑:程序博客网 时间:2024/06/06 02:01
题目:按长度为8拆分每个字符串后输出到新的字符串数组,长度不是8整数倍的字符串请在后面补数字0,空字符串不处理。
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
while(n--)
{
string s;
cin>>s;
int len=s.size();
int i=0;
while(i<len)
{
if(i%8==0&&i!=0)
{
cout<<endl;
}
cout<<s[i];
i++;
}
//当字符串整除时,不需要添加0哦
if(len%8!=0) {
int c=8-len%8;
if(c!=0)
{
while(c--)
cout<<'0';
}
}
cout<<endl;
}
}
return 0;
}
- 分割字符串
- 分割字符串
- 分割字符串
- 分割字符串
- 分割字符串
- 字符串分割
- 字符串分割
- 分割字符串
- 字符串分割
- 字符串分割
- 分割字符串
- 分割字符串
- 分割字符串
- 字符串分割
- 分割字符串
- 字符串分割
- 字符串分割
- 分割字符串
- OSG学习:裁剪变换(1)
- 栈的顺序存储结构的相关操作(数据结构)
- StatusBarUtil 状态栏工具类(实现沉浸式状态栏/变色状态栏)
- io-5-netty-工作原理
- C primer plus(编程练习)file-4.8-7
- 字符串分割
- Git总结
- Elasticsearch 自动重启脚本,同样适用于其他应用
- JavaScript——正则表达式
- 算法训练 Beaver's Calculator
- C primer plus(编程练习)file-4.8-8
- 功能超强的PDF阅读器下载
- HTML学习笔记--3
- 计算余弦距离