题解 | #Hello World for U#

Hello World for U

https://www.nowcoder.com/practice/c6e414fddd7c401887c350c9cc41f01b

#include <cstdio>
#include <string>
#include <map>
#include <cmath>
#include <vector>
#include <climits>
#include <iostream>
#include <algorithm>
#include <bitset>
using namespace std;

int main(){
    string str1;
    int length;
    int max;
    while(cin>>str1){
        string result="                           ";
        length=str1.size();
        for (int i = 0; i < length-2*i; ++i) {
            max=i;
        }
        //max代表n1 n3长度 不包括底部的那一个字符
        for (int i = 0,j=length-1; i<max; ++i,--j) {
            result=result.substr(0,length-2*max-2);
            printf("%c%s%c\n",str1[i],result.c_str(),str1[j]);
        }
        //打印最后一行
        printf("%s\n",str1.substr(max,length-2*max).c_str());
    }
}
全部评论

相关推荐

湫湫湫不会java:先投着吧,大概率找不到实习,没实习的时候再加个项目,然后把个人评价和荣誉奖项删了,赶紧成为八股战神吧,没实习没学历,秋招机会估计不多,把握机会。或者说秋招时间去冲实习,春招冲offer,但是压力会比较大
点赞 评论 收藏
分享
炫哥_:哥们项目描述里面vector和mysql之类的都要写吗,直接开头技术栈巴拉巴拉就行了,完全不是技术点啊
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务