Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 메모리의 불연속적 할당
- 프로세스 동기화
- 자바 알고리즘
- Shared Page
- 코드스테이츠 백엔드 과정 39기
- Page Table의 구현
- Effective Access Time
- Segmentation with Paging
- spring
- CS
- 프로세스 불연속 할당
- jpa
- Allocation of Physical Memory
- 메모리 관리
- 프로세스 할당
- 스프링부트
- Inverted Page Table
- 웹 프로그래밍
- annotation
- 알고리즘
- 리눅스
- 자바 문제풀이
- 웹개발
- 운영체제
- 다단계 페이지 테이블
- 스프링
- linux
- springboot
- 2단계 Page Table
- 문제풀이
Archives
- Today
- Total
GrowMe
[PS] 소수 출력 본문
💡자연수를 받아 해당 수까지의 소수 출력하기 (-) 포함
*Try 1
—> 2만 출력됨. (풀이 실패)
*Search
오랜 고민 끝에, 실제 디버깅 해보니 i가 3일때 실행이 안되며, 안쪽 반복문도 조건문이 잘못되어있음을 깨달음. result 저장문의 위치도 달라져야 하며 여러 생각해야할 부분이 많았음. continu문을 써보기로 함.
*Try 2
public class Sosu {
public static void main(String[] args) {
Solution so = new Solution();
String output = so.listPrimes(12);
System.out.println(output);
}
}
class Solution {
public String listPrimes(int num) {
// TODO:
String result = "2";
Outer : for(int i = 3;i<=num;i++){
for(int j = 2;j < i; j++){
if(i % j == 0){
// break Outer;
continue Outer;
}
}
result = result + '-' + (i+"");
// break;
}
return result;
}
}
Success Solving the Problem!
*후기
반복문이 많이 약하다는 것을 알았으며, continue와 break문의 활용법을 배울 수 있었다. 굉장히 장시간을 투자해 푼만큼 뿌듯하지만 너무 오래걸려버렸다... for문에 대한 이해도도 더 올라간 것 같다.
*Insight
- 반복문에 대한 이해도 상승
- continue문과 break문 활용법
- continue와 break 사용 시, 레이블 활용법
'Algorithm Thinking' 카테고리의 다른 글
[알고리즘 스터디] 트리의 부모 찾기 (0) | 2022.06.30 |
---|---|
[PS] 짐 나르기 문제 (0) | 2022.06.22 |
[PS] 백준 2338번 (0) | 2022.06.22 |
[PS]백준 1550번 (0) | 2022.06.22 |
[PS] 백준 1271번 (0) | 2022.06.22 |
Comments