📜  cpp 中的打印模式和空格 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:45.316000             🧑  作者: Mango

代码示例1
//WAP to print triangle pattern... LOGIC
int num{}, i{1};
  cin >> num;
  while (i <= num) {
    for (int space = 1; space <= (num - i); space++) {  // space
      cout << " ";
    }
    for (int value = 1; value <= (2 * i - 1); value++) {  // value
      cout << value;
    }
    cout << endl; //next row
    i++;
  }