24.06.07 Today I Learned

2024. 6. 8. 10:01·Today I Learned/2024
//
//  main.swift
//  make *****
//
//  Created by t2023-m0112 on 6/7/24.
//

// for문 별찍기
import Foundation

for i in 1...5 { // 세로열
    for j in 1...5 { // 가로열
        print("*", terminator: "") //terminator = 줄바꿈 없이 하는 것
    }
    print("")
}
// *****
// *****
// *****
// *****
// *****


for i in 1...5 { //세로
    for j in 1...i { //가로
        print("*", terminator: "")
    }
    print("")
}
// *____
// **___
// ***__
// ****_
// *****

for i in 0...4 { // o부터 4까지 총 5개 :세로
    for _ in 0..<4-i { //이건 빈칸 : 0<4 = 0,1,2,3 은 빈칸 ____
        print(" ", terminator:"")
    }
    for j in 4-i...4 { //이건 별 : 4-0 = 4부터 4까지는 * -> 4번째만 별 -> [0,1,2,3]은빈칸 [4]는 별
        print("*", terminator: "")
    }
    print("")
}
// ____*
// ___**
// __***
// _****
// *****

for i in 0...4 { //세로
    for _ in 0..<4-i { //빈칸
        print(" ", terminator:"")
    }
    for j in 0..<2*(1+i)-1 { //별
        print("*", terminator: "")
    }
    print("")
}

//공백은1개씩 줄어들고, 별은 2씩 증가함.
// ____*         별이1개
// ___***        별이3개
// __*****       별이5개
// _*******      별이7개
//*********      별이9개



// while 문으로 1부터 10까지 출력하기
var n = 1
while n <= 10 {
    print(n)
    n+=1
}
print("1부터10까지출력")

// while 문으로 &&넣고 1부터 10까지 출력하기 
var a : Int = 1
while 0 < a && a < 11 {
    print(a)
    a+=1
}

// ! = Not !a => a가 트루면 false false 역
// && = AND a && b a랑 b가 둘다 참이면 true 둘중하나라도 아니면 false
// || = OR a || b A or b 둘중 하나라도 true 면 트루, 둘다 틀리면 false

 

https://leedoseo.tistory.com/105
 
 
https://leedoseo.tistory.com/106

[내일배움캠프] 문법 기초 데이터 타입 정리중

데이터 타입숫자Int정수를 표현하는 데이터 타입으로 -2,147,483,648 ~ 2,147,483,647 사이 숫자를 표현할 수 있음var age : Int = 18 // Int 타입 Float소수점을 표현하는 데이터 타입으로 32비트 부동 소수를 표

leedoseo.tistory.com

 
 

'Today I Learned > 2024' 카테고리의 다른 글

24.06.11 Today I Learned  (0) 2024.06.11
24.06.10 Today I Learned  (0) 2024.06.10
24.06.05 Today I Learned  (1) 2024.06.05
24.06.04 Today I Learned  (0) 2024.06.04
24.06.03 Today I Learned  (0) 2024.06.04
'Today I Learned/2024' 카테고리의 다른 글
  • 24.06.11 Today I Learned
  • 24.06.10 Today I Learned
  • 24.06.05 Today I Learned
  • 24.06.04 Today I Learned
이도서
이도서
  • 이도서
    도서의 코딩노트
    이도서
  • 전체
    오늘
    어제
    • 분류 전체보기 (209)
      • Today I Learned (79)
        • 2024 (78)
      • Swift (25)
        • Swift 문법 정리 (19)
        • RxSwift (5)
      • Swift Study (12)
        • Playground (2)
        • Storyboard (9)
        • UIKit (1)
      • Git (3)
      • 코딩테스트 (60)
      • Dart 언어 (16)
      • Flutter (11)
        • Flutter Study (11)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

    • 개발 공부 공유 링크
  • 인기 글

  • 태그

    ios앱개발자
    widget
    Xcode
    Til
    Flutter
    iOS앱개발
    코딩테스트Level.1
    계산기만들기
    함수
    코딩 테스트
    코딩테스트 level.1
    Playground
    코딩테스트
    Swift
    DART
    storyboard
    ios
    구조체
    객체지향
    내일배움캠프
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
이도서
24.06.07 Today I Learned
상단으로

티스토리툴바