输出等腰梯形

1、  请输入高度h,输入一个高为h,上底边长为h的等腰梯形(例如h=4,图形如下)。

****

  ******

 ********

********** 

 1 #include <iostream>
 2 using namespace std;
 3 int main(){
 4     int h;
 5     cout << "请输入h:";
 6     while(cin >> h){
 7         for(int i = 0; i < h; i++){
 8             for(int j = 0; j < h - i - 1; j++){
 9             cout << " ";
10             }
11             for(int k = 0; k < h + 2 * i; k++){
12                 cout << "*";
13             }
14             cout << endl;
15         }
16         cout << "请输入h:";
17     }
18     return 0;
19 }
原文地址:https://www.cnblogs.com/qinduanyinghua/p/6512097.html