Topic description
•Continuous input string, please split each string according to the length of 8 and output it to a new string array;
•For the string whose length is not an integer multiple of 8, please add the number 0 at the back, and the empty string will not be processed.
Enter description:
Continuous input string (input 2 times, each string length is less than 100)
Output description:
output to a new string array of length 8
Example 1
enter
abc 123456789
output
abc00000 12345678 90000000
#include<bits/stdc++.h> using namespace std; void Ps(string s) { if(!s.length()) return; int len = s.length(); int L=0; if(len%8!=0) L = (len / 8 + 1) * 8; else L = len; int dis = L-len; while(dis--) { s.push_back('0'); } for(int i=0;i<L;i++) { printf("%c",s[i]); if((i+1)%8==0) printf("\n"); } } intmain() { string s; while(cin>>s) { Ps(s); } return 0; }