也是相对来说比较简单的例题,直接计算需要循环多少次,然后对其进行循环输出,不足的地方直接补零即可。
#include<iostream>
#include<string.h>
#include<math.h>
using namespace std;
char str[1005];
int count;
int main(){
while(cin.getline(str,1005)){
int len=ceil(strlen(str)*1.0/8);
for(int i=0;i<len;i++){
for(int j=i*8;j<i*8+8;j++){
if(j<strlen(str)){
cout<<str[j];
}else{
cout<<'0';
}
}
cout<<endl;
}
}
return 0;
} 
京公网安备 11010502036488号