分割字符串
来源:互联网 发布:led灯 知乎 编辑:程序博客网 时间:2024/06/05 19:01
#include<bits/stdc++.h>using namespace std;int main(){ int n; string a; while(cin>>n) { while(n--) { cin>>a; int add; if(a.size()%8)add=8-a.size()%8; else add=0; for(int i=0; i<add; i++) a+='0'; for(int i=0; i<a.size(); i++) if(i%8==7)cout<<a[i]<<endl; else cout<<a[i]; } } return 0;}//注意!!!!!!以下为错误写法:a.size()在动态改变,不要作控制变量#include<bits/stdc++.h>using namespace std;int main(){ int n; string a; while(cin>>n) { while(n--) { cin>>a; if(a.size()%8) { for(int i=0; i<8-a.size()%8; i++) a+='0'; } /*应改为: int len=a.size(); if(a.size()%8) { for(int i=0; i<8-len%8; i++) a+='0'; } */ for(int i=0; i<a.size(); i++) if(i%8==7)cout<<a[i]<<endl; else cout<<a[i]; } } return 0;}
阅读全文
0 0
- 分割字符串
- 分割字符串
- 分割字符串
- 分割字符串
- 分割字符串
- 字符串分割
- 字符串分割
- 分割字符串
- 字符串分割
- 字符串分割
- 分割字符串
- 分割字符串
- 分割字符串
- 字符串分割
- 分割字符串
- 字符串分割
- 字符串分割
- 分割字符串
- JVM对类的处理
- storm伪集群环境搭建
- CSS3多列布局——columns用法
- requestmapping
- 人脸3D重构
- 分割字符串
- 序列化与反序列化
- CButton控件:MFC如何给按钮添加图片,显示三种状态,分别是点击、盘旋、初始状态(不点击也不盘旋状态)。
- 案例解读|江苏银行—智多星大数据分析云平台实践
- Python pandas库 数据切片 行列操作
- git免用户名密码push等操作
- 【iOS开发】AsyncSocket长连接粘包问题解决方案
- Spark的异常(一)
- JS之构造函数