---
# System prepended metadata

title: UVA 490 Rotating Sentences

---

# UVA 490 Rotating Sentences 
##  題目連結 [UVA 490](https://vjudge.net/problem/UVA-490)
### 題目內容
In “Rotating Sentences,” you are asked to rotate a series of input sentences 90 degrees clockwise. So instead of displaying the input sentences from left to right and top to bottom, your program will display them from top to bottom and right to left.

### 輸入限制
As input to your program, you will be given a maximum of 100 sentences, each not exceeding 100 characters long. Legal characters include: newline, space, any punctuation characters, digits, and lower case or upper case English letters. (NOTE: Tabs are not legal characters.)

### 輸出限制
The output of the program should have the last sentence printed out vertically in the leftmost column; the first sentence of the input would subsequently end up at the rightmost column.
### 解題思路
1.使用getline讀入陣列，注意算到不是空白為止(a[n]!="")
2.max計算字串的最長長度，為了等等算要輸出多少個空白
3.輸出時當長度小於max就輸出空白。
### 程式碼
```cpp=
#include <iostream>
#include <string>
using namespace std;
int main(){
    string a[101];
    int n=0;
    int max=0;
    while (getline(cin,a[n]) && a[n]!=""){
        if(a[n].length()>max){
            max = a[n].length();
        }
        n++;
    }
    for (int i=0;i<max;i++){
        for (int j=n-1;j>=0;j--){
            if (a[j].length()>i){
                cout<<a[j][i];
            }
            else{
                cout<<' ';
            }
        }
        cout<<endl;
    }
}

```
## 測資
### Sample input
Rene Decartes once said,
"I think, therefore I am."
### Sample output
"R
Ie
n
te
h
iD
ne
kc
,a
r
tt
he
es
r
eo
fn
oc
re
e
s
Ia
i
ad
m,
.
"
##  中文題目連結 [zerojudge c045](https://zerojudge.tw/ShowProblem?problemid=c045)