目录
问题 A: 输出梯形
题目描述
输入一个高度h,输出一个高为h,上底边为h的梯形。
输入
一个整数h(1<=h<=1000)。
输出
h所对应的梯形。
样例输入
5
样例输出
*****
*******
*********
***********
*************
题解
#include <cstdio>
#include <string.h>
int main(){
int h;
while(scanf("%d", &h) != EOF){
int temp;//暂存h
temp = h;
int blank;//空格数
int i, j, k;
for(i = 0; i < h; i++){
blank = 2 * temp - 2;//当前行的空格数
for(j = 0; j < blank; j++){
printf(" ");
}
for(k = blank; k < 3 * h - 2; k++){//当前行剩下的星号数
printf("*");
}
printf("\n");
temp--;//更新下一行
}
}
return 0;
}
问题 B: Hello World for U
题目描述
Given any string of N (>=5) characters, you are asked to form the characters into the shape of U. For example, "helloworld" can be printed as:
h d
e l
l r
lowo
Tha