1061 山形图
Submit solution
Points:
100
Time limit:
1.0s
Memory limit:
32M
Problem types
Allowed languages
C, C++, Java, Python
Description
输入中含有若干组数据,每组数都包含一个字符c和一个正整数n(n≤50),表示边长为n图案为c的山形字符图。一个紧挨一个地打印所有这些山形字符图。
Sample
Input
A 3
M 9
Output
A
AAA
AAAAA
M
MMM
MMMMM
MMMMMMM
MMMMMMMMM
MMMMMMMMMMM
MMMMMMMMMMMMM
MMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMM
Comments
include <iostream>
include <string>
using namespace std;
int main() { char c;
int n;
while (cin >> c >> n) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= n - i; j++) { cout << " "; } for (int j = 1; j <= 2*i - 1; j++) { cout << c; } cout << endl; } cout << endl; } return 0; }