小韦老师@神犇营-my0006-输出等腰三角形

版权声明:本文为博主原创文章,未经博主允许不得转载。如需转载,请与博主联系。 https://blog.csdn.net/qq_31790997/article/details/91355692

小韦老师@神犇营-my0006-输出等腰三角形

题目:

请你写一个程序来输出如下图的一个等腰三角形,行和行之间没有空行。

  *
 ***
*****

题解:

思路:

首先写下 C++ 程序的基本框架,然后用 cout 语句进行输出。注意第一行的前面有 2 个空格,后面没有空格;第二行的前面有 1 个空格,后面没有;第 1 行和第 2 行结束都需要换行。

完整代码:


#include <bits/stdc++.h>

using namespace std;

int main() {
	
	cout << "  *  " << endl;
	cout << " *** " << endl;
	cout << "*****" << endl;
	
	return 0;
}
             

猜你喜欢

转载自blog.csdn.net/qq_31790997/article/details/91355692