您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace _13.流程控制之if语句 { class Program { static void Main(string[] args) { /** * if语句语法及执行过程: * if (<test1>) * { * <code executed if <test1> is true> * } * else if (<test2>) * { * <code executed if <test2> is true> * } * ... * else * { * <code executed if all <test> is false> * } * */ // 求三个整数中的最大值 // if语句版本 { int a = 6, b = 5; string comparison = null; if (a > b) comparison = "greater than"; if (b > a) comparison = "less than"; if (a == b) comparison = "equal to"; Console.WriteLine("{0} is {1} {2}", a, comparison, b); } // if_else语句版本 { int a = 6, b = 5; string comparison = null; if (a > b) { comparison = "greater than"; } else { if (a < b) comparison = "less than"; else comparison = "equal to"; } Console.WriteLine("{0} is {1} {2}", a, comparison, b); } // if_elseif_else语句版本 { int a = 6, b = 5; string comparison = null; if (a > b) { comparison = "greater than"; } else if (a < b) { comparison = "less than"; } else comparison = "equal to"; Console.WriteLine("{0} is {1} {2}", a, comparison, b); } Console.ReadKey(); } } }
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。