裝飾三角形

 avatar
user_3763047219
c_cpp
2 years ago
415 B
1
Indexable
int main(void)
{
	char c1='1',c2='2',c3='3';
	int n = 0;
	//int n = 4;
	//int sum = (n - 1) * 2 + 1;
	scanf(" %c %c %c %d", &c1, &c2, &c3, &n);
	for (int i = 1;i <= n;i++) {
		for (int j = 1;j <= n - i;j++) {
			printf(" ");
		}
		printf("%c", c1);
		for (int j = 1;j <= i - 1;j++) {
			printf("%c%c",c2,c1);
		}
		for (int j = 1;j <= n - i;j++) {
			printf(" ");
		}
		printf("%c\n",c3);

	}
}
Editor is loading...