#include <iostream> #include <string> #define int long long using namespace std; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; cin >> s; int cnt = 0; for(int i = 0; i < s.size(); i++) { cout << s[i]; cnt ++; if(cnt == 8) { cout << endl; cnt = 0; } } if(cnt < 8 && cnt != 0) { for(int i = 0; i < 8 - cnt; i++) { cout << '0'; } } cout << endl; return 0; } // 64 位输出请用 printf("%lld")
这一题有一个值得注意的地方,就是当输入的字符串恰好为8的倍数时的情况。此时,要给cnt为0的情况做出特判,不然就只能wa喽。再水点字数,应该够多了。链接在这里,牛币快到帐。#牛客春招刷题训练营#