일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 플레이그라운드
- 두 정수 사이의 합
- 스위프트공부
- binary operator
- ios
- ===
- string(from)
- 값올리기
- !==
- 42에꼴
- string from
- 42ecole
- html
- 플레이그라운드 문제풀이
- 라피신
- c언어
- swiftlanguage
- ==
- 이노베이션아카데미
- 맥
- ios개발자
- 추적하기
- unary operator
- 짝수와 홀수
- 프로그래머스 문제 풀이
- 프로그래머스
- 스위프트
- Swift
- ternary operator
- playgrounds
- Today
- Total
목록전체 글 (34)
minError

purplePortal.isActive = true while !isBlocked { moveForward() while isOnGem { collectGem() if isBlocked { turnLeft() turnLeft() purplePortal.isActive = false } } if isOnClosedSwitch { toggleSwitch() purplePortal.isActive = true turnLeft() turnLeft() } }

greenPortal.isActive = false func switchOn() { moveForward() moveForward() moveForward() turnLeft() moveForward() moveForward() moveForward() toggleSwitch() turnLeft() turnLeft() } for i in 1 ... 3 { switchOn() }
스위프트 언어 에서 while문과 repeat while문의 차이점 먼저, 아래의 예제 코드처럼 입력을 하게 되면? print("---while") var i = 10 while i 코드 수행 > 조건 > 코드수행' repeat while은? '코드 수행 > 조건 > 코드수행 > 조건' 순서대로 인식을 한다고 보시면 됩니다.

let totalGems = randomNumberOfGems var gemCounter = 0 while gemCounter < totalGems { while !isBlocked { if is OnGem { collectGem() gemCounter += 1 } moveForward() } if isBlocked && isBlockedLeft { turnRingt() } else if isBlocked && isBlockedRight { turnLeft() } }

//1. 보석과 스위치의 갯수 세아리는 변수 생성. var swithchCounter = 0 var gemCounter = 0 while switchCounter < gemCounter || switchCounter == 0 { while !isBlocked { //2. 첫번째, 발판 보석 수집하고, 수량 세아리기 if isOnGem { collectGem() gemCounter += 1 } moveForward() } //3. 두번째, 수집한 보석의 갯수만큼 스위치 작동 if isOnClosedSwitch && switchCounter < gemCounter { toggleSwitch() switchCounter += 1 } turnRight() }