题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include<iostream> #include<vector> using namespace std; int main() { string str ={0}; cin>> str; int lastlen = str.length()%8; int len1 = 8 - str.length()%8; for(int i=0;i<=(str.length()/8);i++) { for(int j=0;j<8;j++) { if (i<str.length()/8) { cout<<str[i*8+j]; if (j==7) cout<<endl; } else { if(j==lastlen) break; cout<<str[i*8+j]; } } } if (lastlen!=0) { for(int k=0;k<len1;k++) cout<<'0'; } return 0; }
反正就是,奇奇怪怪