Swift-Control statements

Source: Internet
Author: User

main.swift//Control Statement -03//import foundationprintln ("Hello, world!") Define a fraction var score = 80;/*** Define an array */var Scorearr = [90,99,45,89,67,54];var minscore = 0;var Maxscore = 0;var Avgscore = 0    .0;var Sumscore = 0.0;var count = scorearr.count;//loop all yuansfor s in scorearr{sumscore = Sumscore + Double (s);    println ("s is \ (s)"); if (Minscore = = 0| |    Minscore > s) {minscore = s; } if (Maxscore = = 0| |    Maxscore < s) {Maxscore = s; }}avgscore = sumscore/double (count);p rintln ("Sumsocre is \ (sumscore) Avgscore are \ (avgscore)");p rintln ("Maxscore is \ ( Maxscore) Minscore is \ (Minscore) "), for (var i = 0; i < count; i++) {var s = scorearr[i];//get Iyuans println (" for    ... i\ (i) s = \ (s) "); if (Minscore = = 0| |    Minscore > s) {minscore = s; } if (Maxscore = = 0| |    Maxscore < s) {Maxscore = s; }}avgscore = sumscore/double (count);p rintln ("Sumsocre is \ (sumscore) Avgscore are \ (avgscore)");p rintln ("Maxscore is \ ( Maxscore) Minscore is \ (Minscore); var index = 0;do{if (index >= count) {break;    } var s = Scorearr[index]; println ("Do-while s[\ (Index)]=\ (s)");    while (++index < count); index = 0;while (Index < count) {index++;    if (index >= count) {break;    } var s = Scorearr[index]; println ("while s[\ (index)] = \ (s)");}        Switch before switch will penetrate let Apptype = "ios", switch apptype{case "ios": println ("ios development");    fallthrough;//let's go down case "Android": println ("Android Dev"); Case "Java": println ("Java development");d Efault:println ("no Match");}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Swift-Control statements

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.