PAT_1031. Hello World for U

来源:互联网 发布:mac怎么保存文档 编辑:程序博客网 时间:2024/05/20 20:03
////  main.cpp//  PAT_1031. Hello World for U////  Created by wjq on 17/4/15.//  Copyright © 2017年 wjq. All rights reserved.//#include <iostream>#include <string.h>using namespace std;char str[100];int main(int argc, const char * argv[]){    cin>>str;    int start=0,end=(int)strlen(str)-1;    int row=0,column=0,length=(int)strlen(str);    row=(length+2)/3;    column=(length+2)-2*row;    for(int i=0;i<row;i++)    {        if(i!=row-1)        {            for(int j=0;j<column;j++)            {                if(j==0)                    cout<<str[start++];                else if(j==column-1)                    cout<<str[end--];                else                    cout<<" ";            }            cout<<endl;        }        else        {            for(int j=0;j<column;j++)                cout<<str[start++];            cout<<endl;        }    }}


简单题

0 0
原创粉丝点击