牛客华为机测-3-字符串分割

#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;

int main(void) {
    char s[110] = {0};    //用字符数组存放字符串
    char out[9] = {0};
    while (gets(s)) {
        char *p = s;       //用字符指针管理串P125
        while (*p) {
            for(int i=0; i<8; i++) {
                if(p[i])
                    out[i] = p[i];
                else
                    out[i] = '0';
            }
            cout<<out<<"\n";
            p += 8;         //p分配新地址
        }
        memset(s, 0, 110);
    }
    return 0;
}
发布了0 篇原创文章 · 获赞 0 · 访问量 67

猜你喜欢

转载自blog.csdn.net/qq_36587311/article/details/104600710