zoukankan      html  css  js  c++  java
  • Swift 循环语句

     // 循环语句

            for var i = 0 ;i < 5 ;i++ {

                

                print("i = (i)")

            }

            

            var j = 0

            for j = 0; j < 10; j++ {

                

                print("j = (j)")

                

            }

            

            // for in 的第一种用法

            // 1.遍历字符串

            let str = "qwertyu"

            

            for temp in str.characters {

                

                print("temp = (temp)")

            }

            

            

            for temp1 in 1...6 {

                print("temp1 = (temp1)")

            }

            

            // while 语句

            /*

            格式

            

            while  布尔值

            

            说明

            

            只有当while 后面的布尔值为false ,才停止 while语句,否则一直执行while语句

            */

            

            var x = 0

            

            while (x < 3)

            {

                print("x = (x)")

                

                x++

                

            }

            

            // repeat while

            /*

            格式:

            repeat {} while 布尔值

            

            说明:

            1:现在执行 repeat 语句

            2:然后在执行while 语句

            3:如果while语句后面的布尔值为false 就停止repeat  while语句,否则就一直执行repeat  while语句

            */

            

            var y = 0

            repeat {

                

                y = y + 1

                

                print("y = (y)")

                

            }while (y < 5)

    1
  • 相关阅读:
    想更改Github仓库中的某个文件结构
    记git一些基本用法
    剑指Offer-Python(16-20)
    剑指Offer-Python(11-15)
    初次使用flask
    Python的Cmd模块的简易运用学习
    SQL-全称量词查询
    线段树模板1
    OJ输入输出超时(C++)
    二叉查找树(BST)定义
  • 原文地址:https://www.cnblogs.com/fantasy3588/p/5083336.html
Copyright © 2011-2022 走看看