从标准输入设备读入正整数n和字符ch, 输出一个由字符ch组成的字符三角形.
Standard Input
第一行是T(T<=100),表明后面有T组测试数据,每组测试数据由正整数n(n<=30)和字符ch构成,两者之间有一个空格。
Standard Output
对应每一组测试数据,输出符合要求的字符三角形, 两组结果之间有一个空行。
Samples
| Input | Output |
|---|---|
3 1 9 3 * 6 X |
9 * ** *** X XX XXX XXXX XXXXX XXXXXX |
| Problem ID | 1885 |
| Problem Title | 字符三角形 |
| Time Limit | 1000 ms |
| Memory Limit | 64 MiB |
| Output Limit | 64 MiB |
| Source | wxiaoping - 2018.4.16 |
1 #include<cstdio> 2 #include<cstring> 3 #include<cmath> 4 #include<algorithm> 5 #include<iostream> 6 using namespace std; 7 8 int main(){ 9 int t,n; 10 char ch; 11 scanf("%d",&t); 12 for(int i=1;i<=t;i++){ 13 scanf("%d %c",&n,&ch); 14 for(int j=1;j<=n;j++){ 15 for(int k=1;k<=j;k++){ 16 printf("%c",ch); 17 } 18 printf("\n"); 19 } 20 } 21 return 0; 22 }