본문 바로가기 메뉴 바로가기

Peppo

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

Peppo

검색하기 폼
  • 분류 전체보기 (222)
    • Story (13)
    • iOS (144)
      • Error (11)
    • 알고리즘 (43)
    • ETC (7)
    • React-Native (0)
    • CS (Computer science) (3)
  • 방명록

Swift while (2)
[Swift 알고리즘] - 콜라츠 추측 (Programmers)

https://programmers.co.kr/learn/courses/30/lessons/12943 코딩테스트 연습 - 콜라츠 추측 1937년 Collatz란 사람에 의해 제기된 이 추측은, 주어진 수가 1이 될때까지 다음 작업을 반복하면, 모든 수를 1로 만들 수 있다는 추측입니다. 작업은 다음과 같습니다. 1-1. 입력된 수가 짝수라면 2 programmers.co.kr 내 풀이 func solution(_ num:Int) -> Int { var count = 0 var number = num let noResult = -1 while number != 1 { if number % 2 == 0 { number = number / 2 count += 1 } else if number % 2 == 1 ..

알고리즘 2022. 5. 13. 14:30
[Swift] Control Flow 1-1 반복문(for-in, while)

Control Flow Swift에서는 while, if guard, switch, for-in 문 등 많은 제어문을 제공합니다. 내용이 많아 2개로 나눠서 정리해보려고 합니다 조건문은 따로 정리할게요 ! For-in Loops for-in 문은 배열, 숫자, 문자열을 순서대로 순회 하기 위해 사용합니다. let names = ["Roy", "Daisy", "Lily", "Jason"] for name in names { print("Hello, \(name)!") } // Hello, Roy! // Hello, Daisy! // Hello, Lily! // Hello, Jason! dictionary에서 반환된 key-value 로 구성된 튜플을 순회하며 제어할 수도 있습니다. ※ dictionary에..

iOS 2022. 1. 9. 18:43
이전 1 다음
이전 다음
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
  • Peppo's Github
TAG
  • Swift final
  • RTCCameraVideoCapturer
  • Swift 프로퍼티
  • Class
  • Combine: Asynchronous Programming with Swift
  • Swift ModernRIBs
  • Swift
  • swift programmers
  • Swift init
  • swift 고차함수
  • swift reduce
  • 2023년 회고
  • Swift Error Handling
  • Swift joined()
  • ios
  • Swift joined
  • Swift 내림차순
  • Swift RIBs
  • swift property
  • Swift 알고리즘
  • Swift inout
  • 원티드 프리온보딩
  • swift (programmers)
  • iOS error
  • Swift Leetcode
  • removeLast()
  • CS 네트워크
  • RIBs tutorial
  • Swift 프로그래머스
  • swift protocol
more
«   2026/04   »
일 월 화 수 목 금 토
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
글 보관함

Blog is powered by Tistory / Designed by Tistory

티스토리툴바