C++根据用户输入打印对应的金层塔层数
#include <iostream> #include <Windows.h> using namespace std; int main(void) { int row; cout << "请输入金字塔层数:"; cin >> row; for (int i = 1; i <= row; i++) { for (int k = 0; k < row - i; k++) { cout << " "; } for (int j = 0; j < (2 * i) - 1; j++) { cout << "*"; } cout << endl; } system("pause"); return 0; }