当前位置: 首页 > news >正文

网站建设个人博客中山做网站的公司

网站建设个人博客,中山做网站的公司,吉林网站建设找哪家,如何建立和设计公司的网站#x1f4d2;博客首页#xff1a;Sonesang的博客 #x1f389;欢迎关注#x1f50e;点赞#x1f44d;收藏⭐️留言#x1f4dd; ❤️ #xff1a;热爱Java与算法学习#xff0c;期待一起交流#xff01; #x1f64f;作者水平很有限#xff0c;如果发现错误#xf… 博客首页Sonesang的博客 欢迎关注点赞收藏⭐️留言 ❤️ 热爱Java与算法学习期待一起交流 作者水平很有限如果发现错误求告知多谢 有问题可私信交流 一、if 语句 1. 基本if-else语句 当条件成立时执行某些语句否则执行另一些语句。 import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc new Scanner(System.in);int a sc.nextInt();if (a 5) {System.out.printf(%d is big!\n, a);System.out.printf(%d 1 %d\n, a, a 1);} else {System.out.printf(%d is small!\n, a);System.out.printf(%d - 1 %d\n, a, a - 1);}} } else 语句可以省略 import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc new Scanner(System.in);int a sc.nextInt();if (a 5) {System.out.printf(%d is big!\n, a);System.out.printf(%d 1 %d\n, a, a 1);}} } 当只有一条语句时大括号可以省略 import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc new Scanner(System.in);int a sc.nextInt();if (a 5)System.out.printf(%d is big!\n, a);elseSystem.out.printf(%d is small!\n, a);} } 练习输入一个整数输出这个数的绝对值。 import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc new Scanner(System.in);int x sc.nextInt();if (x 0)System.out.println(x);elseSystem.out.println(-x);} } 练习输入两个整数输出两个数中较大的那个。 import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc new Scanner(System.in);int a sc.nextInt(), b sc.nextInt();if (a b)System.out.println(a);elseSystem.out.println(b);} } if-else语句内部也可以是if-else语句。 练习输入三个整数输出三个数中最大的那个。 import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc new Scanner(System.in);int a sc.nextInt(), b sc.nextInt(), c sc.nextInt();if (a b) {if (a c)System.out.println(a);elseSystem.out.println(c);} else {if (b c)System.out.println(b);elseSystem.out.println(c);}} } 2. 常用比较运算符 (1) 大于 (2) 小于 (3) 大于等于 (4) 小于等于 (5) 等于 (6) 不等于 ! import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc new Scanner(System.in);int a sc.nextInt(), b sc.nextInt();if (a b) System.out.printf(%d %d\n, a, b);if (a b) System.out.printf(%d %d\n, a, b);if (a b) System.out.printf(%d %d\n, a, b);if (a b) System.out.printf(%d %d\n, a, b);if (a b) System.out.printf(%d %d\n, a, b);if (a ! b) System.out.printf(%d ! %d\n, a, b);} } 3. if-else连写 输入一个0到100之间的分数 如果大于等于85输出A 如果大于等于70并且小于85输出B 如果大于等于60并且小于70输出C 如果小于60输出 D import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc new Scanner(System.in);int s sc.nextInt();if (s 85) {System.out.println(A);} else if (s 70) {System.out.println(B);} else if (s 60) {System.out.println(C);} else {System.out.println(D);}} } 练习 1.判断闰年。闰年有两种情况 (1) 能被100整除时必须能被400整除 (2) 不能被100整除时被4整除即可。 输入一个年份如果是闰年输出yes否则输出no。 import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc new Scanner(System.in);int year sc.nextInt();if (year % 100 0) {if (year % 400 0)System.out.println(yes);elseSystem.out.println(no);} else {if (year % 4 0)System.out.println(yes);elseSystem.out.println(no);}} } 二、条件表达式 (1) 与 (2) 或 || (3) 非 ! 例题输入三个数输出三个数中的最大值。 import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc new Scanner(System.in);int a sc.nextInt(), b sc.nextInt(), c sc.nextInt();if (a b a c)System.out.println(a);else if (b a b c)System.out.println(b);elseSystem.out.println(c);} } 练习用一条if语句判断闰年。 import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc new Scanner(System.in);int year sc.nextInt();if (year % 4 0 year % 100 ! 0 || year % 400 0)System.out.println(yes);elseSystem.out.println(no);} } 三、switch 语句 注意 swtich语句中如果不加break语句则从上到下匹配到第一个case后会顺次执行后面每个case中的语句。 import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc new Scanner(System.in);int day sc.nextInt();String name;switch(day) {case 1:name Monday;break;case 2:name Tuesday;break;case 3:name Wednesday;break;case 4:name Thursday;break;case 5:name Friday;break;case 6:name Saturday;break;case 7:name Sunday;break;default:name not valid;}System.out.println(name);} }
http://www.hkea.cn/news/14456681/

相关文章:

  • 阜宁做网站公司开发门户网站报价
  • 怎样添加网站上百度商桥代码手机网站策划书
  • 同江佳木斯网站设计大型网站 php
  • 做网站商城需要多少钱华为云服务器购买
  • 建设银行网站用户名阿里邮箱企业版登录入口
  • 做网站服务器有哪些石油化工工程建设人才招聘网站
  • 章丘哪里有建设网站的怎么做网站 有空间
  • 互联网网站 数据库手机快速建站
  • 公司网站seo公司怎么建设游戏试玩平台网站
  • linux如何架设网站织梦商城网站
  • 自己做盈利视频网站麻将网站开发
  • 做公司网站怎么删除图片抚州的电子商务网站建设公司
  • 网站建设中 模板wordpress禁用谷歌字体
  • 佛山网站设计外包番禺网站推广公司
  • .net 网站域账号自动验证码亚马逊查关键词排名工具
  • 温州购物网络商城网站设计制作建筑工程网络计划图绘制软件
  • 平面设计公司网站外贸公司系统管理软件
  • 蚌埠企业做网站房地产开发商是干什么的
  • 网站页面策划如何寻找做企业网站的
  • dede网站制作外包公司能不能去
  • 网站分为哪些类型菠菜网站怎样做安全
  • 怎么用h5网站做动效百度竞价广告点击器
  • 免费的海报模板网站做欧美贸易的主要有哪些网站
  • 网址的输入格式是什么样的深圳优化新材料
  • 用别人家网站做跳转网站如果实现微信支付
  • 佛山网站seo推广推荐企业手机网站建设策划方案
  • 中国建设银行网站E路护航官网wordpress后台设置
  • wordpress上传ftp设置密码淄博seo定制
  • 找人做网站怕侵权领导交给你一个网站你该怎么做
  • 合肥网站建设创优外贸软件排行榜前十名