힘들게했는데,,, 입력 뒷줄에 공백이 들어가면 안됬었네요,,,, 이런..
StringBuilder stringBuilder = new StringBuilder();
int put = int.Parse(Console.ReadLine());
for(int i = 1; i <= put; i++) {
if(i-1 < put) {
for(int j = 1; j <= put * 2 - 1 ; j++) {
int count = j / put < 1 ? j * 2 - 1 : (j - j % put * 2) * 2 - 1;
int blankCount = (count / 2) + 1;
if((put < blankCount + put - (put - i))) {
stringBuilder.Append("*");
}
else {
stringBuilder.Append(" ");
}
}
}
stringBuilder.Append("\n");
}
for(int i = put - 1; i >= 1; i--) {
if(i-1 < put) {
for(int j = 1; j <= put * 2 - 1 ; j++) {
int count = j / put < 1 ? j * 2 - 1 : (j - j % put * 2) * 2 - 1;
int blankCount = (count / 2) + 1;
if((put < blankCount + put - (put - i))) {
stringBuilder.Append("*");
}
else {
stringBuilder.Append(" ");
}
}
}
stringBuilder.Append("\n");
}
Console.Write(stringBuilder);
정답판정 받았습니다!! 공백때문이였어요.
StringBuilder stringBuilder = new StringBuilder();
int put = int.Parse(Console.ReadLine());
for(int i = 1; i <= put; i++) {
if(i-1 < put) {
for(int j = 1; j <= put * 2 - 1 ; j++) {
int count = j / put < 1 ? j * 2 - 1 : (j - j % put * 2) * 2 - 1;
int blankCount = (count / 2) + 1;
if((put < blankCount + put - (put - i))) {
stringBuilder.Append("*");
}
else if(j >= put){
break;
} else {
stringBuilder.Append(" ");
}
}
}
stringBuilder.Append("\n");
}
for(int i = put - 1; i >= 1; i--) {
if(i-1 < put) {
for(int j = 1; j <= put * 2 - 1 ; j++) {
int count = j / put < 1 ? j * 2 - 1 : (j - j % put * 2) * 2 - 1;
int blankCount = (count / 2) + 1;
if((put < blankCount + put - (put - i))) {
stringBuilder.Append("*");
}
else if(j >= put){
break;
}
else {
stringBuilder.Append(" ");
}
}
}
stringBuilder.Append("\n");
}
Console.Write(stringBuilder);