游客 Signup | Login
中文 | En

2888 - 基础图案3

打印相应的N层数字金字塔。 如果输出的数字超过9,就用相应的字符表示。10用A表示,11用B表示…… 

Input

一行:整数n,(0<n<20)

Output

若干行,左右对称的数字金字塔。

Examples

Input

5

Output

    1
   121
  12321
 1234321
123454321

Solution C++

# include <iostream>
using namespace std;
char a[30] = "0123456789ABCDEFGHIJKLMN";
int main(){
    int n;
    cin >> n;
    for (int i = 1; i <= n; i ++){
        for (int j = 1; j <= n - i; j ++){
            cout << " ";
        }
        for (int j = 1; j <= i; j ++){
            cout << a[j];
        }
        for (int j = i - 1; j >= 1; j --){
            cout << a[j];
        }
        cout << endl;
    }
    return 0;
}
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题