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 }

 

相关文章:

  • 2022-12-23
  • 2021-07-21
  • 2022-12-23
  • 2022-12-23
  • 2021-11-14
  • 2022-12-23
  • 2021-10-22
  • 2022-03-09
猜你喜欢
  • 2022-12-23
  • 2022-01-17
  • 2022-12-23
  • 2021-10-13
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
相关资源
相似解决方案