倒三角形C++实现

C++:
#include<stdio.h>
#include<iostream>
#include<math.h>

using namespace std;
int main()
{
	int n;
	while (cin >> n)
	{
		for (int j = 0; j<n; j++)
		{
			for (int k = 0; k<j; k++)cout << " ";
			for (int i = 1; i <= 2 * (n - j) - 1; i++)
				cout << "#";
			cout << endl;
		}
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_38734403/article/details/80437382