CS/Algorithm 문제
[BaekJoon] 백준 2442번 별찍기 - 5
심심231
2020. 4. 17. 01:00
[BaekJoon] 백준 2442번 별찍기 - 5
문제: https://www.acmicpc.net/problem/2442
내코드
#include <string.h>
#include <iostream>
using namespace std;
int main(void) {
ios::sync_with_stdio(false);
cin.tie(0);
int n = 0; cin >> n;
for (int j = 1; j <= n; j++) {
for (int i = 0; i < n - j; i++) {
printf(" ");
}
for (int k = 0; k < (j - 1) * 2 + 1; k++) {
printf("*");
}
printf("\n");
}
for (int i = 0; i < n; i++) {
printf(" ");
}
return 0;
}
참고
728x90
반응형