for循环写法
查看原帖
for循环写法
922091
ososos楼主2024/8/10 00:11
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//	int n;
//	cin >> n;
	int n = 3;
	char c;
	cin >> c;
	for(int i = 1; i <= n; i ++)//行数
	{
		for(int j = 1; j <= n - i; j ++)//空格数 
			cout << ' ';
		for(int k = 1; k <= 2 * i - 1; k ++)//字符数
			cout << c ;
		cout << endl;
	}
    return 0;
}

2024/8/10 00:11
加载中...