C++ 打印一個三角形
#include <iostream>
using namespace std;
int main() {
? ? int i, j;
? ? int n = 10;
? ? for (i = 0; i < n; i++) {
? ? ? ? for (j = 0; j < n - i - 1; j++)
? ? ? ? ? ? cout << " ";
? ? ? ? for (j = n - i - 1; j < n + i; j++)
? ? ? ? ? ? cout << "*";
? ? ? ? cout << "\n";
? ? }
? ? cout << endl;
}

標(biāo)簽: