Skip to content

Conversation

@heegane
Copy link
Collaborator

@heegane heegane commented May 16, 2024

240516 이현희 0x02 풀이

@heegane heegane self-assigned this May 16, 2024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전체적으로 저랑 똑같이 하셨네요!!!
저는 스캐너 대신 BufferedReader랑 StringTokenizer를 사용하였는데,
입출력시 속도 차이가 있어서, 나중엔 같은 구문이더라도, 스캐너를 사용하면
런타임 에러가 뜨는 경우가 있더라구요!!
이부분도 한 번 확인해보시면 좋을 것 같습니다!!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전 가운데까지 포함해서 위~ / 아래 이렇게 구현했었는데,
현희님 방식처럼 위 - 가운데 - 아래 도 깔끔하게 보기 좋네요!!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전 이부분 구현을 똑바로 못했어서
왼쪽공백 / 오른쪽 공백 느낌으로 반복문을 두 번 사용하였는데,
이렇게 구현하면 한번에 가능하네요!! 배워갑니다.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 윗 삼각형 부분을 이런식으로 구현했습니다.

for (int i = 0; i <n; i++) { // 윗 삼각형
for (int j = 0; j < i; j++) { // 공백
sb.append(" ");
}
for (int j = 1; j <= 2*(n-i)-1; j++) { // 별
sb.append("*");
}
sb.append("\n"); // 줄 바꿈
}

큰 반복문 부분에서 저는 i값이 0부터 증가하는 것으로 구현하였는데,
현희님은 반대로 n-1부터 감소하는 느낌으로 구현하셨네요!
한 번 비교해보셔도 좋을 것 같아서 올려봅니다!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 Collections를 응용해서 해결하고 싶었는데, 자꾸 오류가 나서 실패했었어요
Collections.sort만 생각했는데, max를 활용하는 건 생각 못했네요
배워갑니다.

@lee-JunR lee-JunR merged commit cd94e90 into lee-JunR:main May 17, 2024
@heegane heegane removed their assignment May 21, 2024
lee-JunR pushed a commit that referenced this pull request Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants