http://ac.jobdu.com/problem.php?cid=1040&pid=13
- 题目描述:
-
输入一个高度h,输出一个高为h,上底边为h的梯形。
- 输入:
-
一个整数h(1<=h<=1000)。
- 输出:
-
h所对应的梯形。
- 样例输入:
-
4
- 样例输出:
-
**** ****** ******** **********
- 提示:
-
梯形每行都是右对齐的,sample中是界面显示问题
// 题目14:输出梯形.cpp: 主项目文件。 #include "stdafx.h" #include <cstdio> #include <cstring> int main() { int n; while(scanf("%d",&n)!=EOF) { int count=n+2*(n-1); for(int i=1;i<=n;i++) { int tmp=count-(n+2*(i-1)); for(int j=1;j<=tmp;j++) printf(" "); for(int j=tmp+1;j<=count;j++) printf("*"); printf("\n"); } } return 0; }