oj 输出梯形
# include <iostream> using namespace std ; int main ( ) { int h ; while ( scanf ( "%d" , & h ) != EOF ) { int maxLine = h + ( h - 1 ) * 2 ; for ( int i = 1 ; i <= h ; i ++ ) { for ( int j = 1 ; j <= maxLine ; j ++ ) { if ( j < ( maxLine - h - ( i - 1 ) * 2 + 1 ) ) cout << " " ; else cout << "*" ; } cout << endl ; } } } 来源: CSDN 作者: Leonjang 链接: https://blog.csdn.net/weixin_38023259/article/details/104080915