分支语句: if else if else : switch case --如何使用 if else if else: Console.WriteLine("请你出拳"); --输出[请你出拳] int a = Convert.ToInt32(Console.ReadLine()); --定义一个变量a Random i = new Random(); --随机数 …
分支语句:判断结构要求程序员指定一个或多个要评估或测试的条件,以及条件为真时要执行的语句(必需的)和条件为假时要执行的语句(可选的). 分支语句 if if(判断条件表达式) {//表达式结果为ture时执行} else {//表达式结果为false时执行} For example Console.WriteLine("请输入一个数字:"); int iInput = Convert.ToInt32(Console.ReadLine());//记录用户的输入 != )//使用if语句…
条件语句 分支语句和循环语句是程序里最重要的逻辑. IF语句.分支语句.循环语句 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace w1d4_if { class Program { static void Main(string[] args) { #region if语句 //if语句是C#中…
循环 for循环 while循环 do while循环 通常,入口条件循环比出口条件循环好,因为循环开始前对条件进行检查 c++11基于范围的for循环 对数组(或容器类,如:vector和array)的每个元素执行相同操作 int a[5]={1,3,4,5,6}: for (int i :a) cout<<i<<endl; //////不断循环把依次打印出来 int a[5]={1,3,4,5,6}: …