---
title: "PAT1031 Hello World for U"
author: "风吹过PP好冷"
date: "2012-11-22T23:54:37Z"
tags: []
categories: ["非技术"]
slug: "pat1031-hello-world-for-u"
draft: false
lastmod: "2012-11-22T23:56:53Z"
id: 1733674
url: "https://ppcool.iteye.com/blog/1733674"
---

**Sample Input:**

```
helloworld!
```

**Sample Output:**

```
h   !
e   d
l   l
lowor
```

 

 

 

 

 

 

 

```
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

int main()
{
    string str;
    cin>>str;
    int length = str.length();
    int n1 = length/3;
    int n2;
    if (length%3 == 0)
    {
        n1--;
        n2 = n1 + 3;
    }
    else
    {
        n2 = n1 + length%3;
    }
    for (int i = 0; i < n1; i++)
    {
        cout<<str[i];
        for (int j = 0; j < n2 - 2; j++)
        {
            cout<<" ";
        }
        cout<<str[length - 1 -i]<<endl;
    }
    for (int i = length - n1 - n2; i < length - n1; i++)
    {
        cout<<str[i];
    }
    return 0;
}
```