[정올] Language Coder_반복제어문3_자가진단4_code551 (C)

두비니

·

2020. 4. 4. 00:20

 

C언어

#include <stdio.h>

int main() {

	int n;

	scanf("%d", &n);

	for (int i = n; i >= 1; i--) {
		for (int j = 0; j < n - i; j++) {
			printf(" ");
		}
		for (int j = 0; j < i; j++) {
			printf("*");
		}
		printf("\n");
	}


	return 0;
}

 

Python

n = int(input())

for i in range(n, 0, -1):
    print(" "*(n-i), end="")
    print("*"*i)