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

大连微网站开发济宁网站制作

大连微网站开发,济宁网站制作,seo全网优化指南,wordpress情侣模板下载常用API——练习 练习1 键盘录入#xff1a;练习2 算法水题#xff1a;练习3 算法水题#xff1a;练习4 算法水题#xff1a;练习5 算法水题#xff1a; 练习1 键盘录入#xff1a; 键盘录入一些1~100之间的整数#xff0c;并添加到集合中。 直到集合中所有数据和超过2… 常用API——练习 练习1 键盘录入练习2 算法水题练习3 算法水题练习4 算法水题练习5 算法水题 练习1 键盘录入 键盘录入一些1~100之间的整数并添加到集合中。 直到集合中所有数据和超过200为止 public static void main(String[] args) {/*键盘录入一些1~100之间的整数并添加到集合中。直到集合中所有数据和超过200为止*///0.创建一个集合用来添加数据ArrayListInteger list new ArrayList();//1.键盘录入数据Scanner sc new Scanner(System.in);while (true) {System.out.println(请输入一个整数);String numStr sc.nextLine();int num Integer.parseInt(numStr);//数据异常判断if (num 1 || num 100) {System.out.println(当前数字不在1~100的范围当中请重新输入);continue;}/*将数据添加到集合中* 细节* num:基本数据类型* 集合里面的数据是Integer* 在添加数据的时候触发了自动装箱*/list.add(num);//统计数据中所有的数据和int sum getSum(list);//对sum进行判断if (sum 200){System.out.println(集合中所有的数字满足要求);break;}}//验证要求for (int i 0; i list.size(); i) {System.out.print(list.get(i) );}}private static int getSum(ArrayListInteger list) {int sum 0;for (int i 0; i list.size(); i) {int num list.get(i);sum num;}return sum;}练习2 算法水题 自己实现parseInt方法的效果将字符串形式的数据转成整数。 要求 字符串中只能是数字不能有其他字符最少一位最多10位0不能开头 public static void main(String[] args) {/*自己实现parseInt方法的效果将字符串形式的数据转成整数。要求字符串中只能是数字不能有其他字符最少一位最多10位0不能开头*///0.定义一个字符串String str 123456789;//1.校验字符串//习惯会先把异常数据进行过滤剩下来就是正常的数据if (!str.matches([1-9]\\d{0,9})) {//错误的数据System.out.println(数据格式有误);} else {//正确的数据System.out.println(数据格式正确);//2. 定义一个变量表示最终的结果int num 0;//3.遍历字符串得到里面的每一个字符for (int i 0; i str.length(); i) {int c str.charAt(i) - 0;num num * 10 c;}System.out.println(num);}}练习3 算法水题 定义一个方法自己实现toBinaryString方法的效果将一个十进制整数转成字符串表示的二进制 public static void main(String[] args) {/*定义一个方法自己实现toBinaryString方法的效果将一个十进制整数转成字符串表示的二进制*/System.out.println(toBinaryString(123));//验证System.out.println(Integer.toBinaryString(123));}private static String toBinaryString(int num) {/*核心逻辑:不断地去除以2得到余数一直到商为0就结束* 需要把余数倒着拼接起来*///0.定义一个StringBuilder()用来 拼接余数StringBuilder sb new StringBuilder();//1.利用循环不断地除以2获取余数while (true){if (num0) break;//获取余数int remaindar num % 2;//倒着拼接sb.insert(0,remaindar);//除以2num num / 2;}return sb.toString();}练习4 算法水题 请使用代码实现计算你活了多少天用JDK7和JDK8两种方法实现 public static void main(String[] args) throws ParseException {//请使用代码实现计算你活了多少天用JDK7和JDK8两种方法实现//JDK7//规则只要对时间进行计算或者判断都需要先获取当前时间的毫秒值//0.计算出生年月日的毫秒值String birthday 2002年4月11日;SimpleDateFormat sdf new SimpleDateFormat(yyyy年MM月dd日);Date date sdf.parse(birthday);long birthdaytime date.getTime();//1.获取当前时间的毫秒值long todayTime System.currentTimeMillis();//2.计算间隔多少天long time todayTime - birthdaytime;System.out.println(time / 1000 / 60 / 60 / 24 天);//--------------------------//JDK8LocalDate d1 LocalDate.of(2002, 4, 11);LocalDate d2 LocalDate.now();long days ChronoUnit.DAYS.between(d1, d2);System.out.println(days 天);}练习5 算法水题 判断任意的一个年份是闰年还是平年 要求用JDK7和JDK8两种方式判断 提示 二月有29天是闰年一年又366天是闰年 public static void main(String[] args) {/*判断任意的一个年份是闰年还是平年要求用JDK7和JDK8两种方式判断提示* 二月有29天是闰年* 一年又366天是闰年*///JDK7//方法1JDK7Method1();//方法2JDK7Method2();//JDK8//方法1JDK8Method1();//方法2//把时间设置为2000年3月1日LocalDate ld LocalDate.of(2000, 3, 1);//true:闰年 false平年boolean result ld.isLeapYear();System.out.println(result);if (result){System.out.println(ld.getYear() 年是闰年);}else {System.out.println(ld.getYear() 年是平年);}}private static void JDK8Method1() {//把时间设置为2000年3月1日LocalDate ld LocalDate.of(2000, 3, 1);//再把日历往前减一天LocalDate ld2 ld.minusDays(1);//看当前的时间是28号还是29号int dayOfMonth ld2.getDayOfMonth();System.out.println(dayOfMonth);if (dayOfMonth29){System.out.println(ld2.getYear() 年是闰年);}else {System.out.println(ld2.getYear() 年是平年);}}private static void JDK7Method2() {/*简化2* 我们可以把时间设置为2001年1月1日*/Calendar c Calendar.getInstance();c.set(2001,0,1);//再把日历往前减一天c.add(Calendar.DAY_OF_MONTH, -1);//看当前的时间是有366天还是365天int dayofYear c.get(Calendar.DAY_OF_YEAR);System.out.println(dayofYear);if (dayofYear366){System.out.println(c.get(Calendar.YEAR) 年是闰年);}else {System.out.println(c.get(Calendar.YEAR) 年是平年);}}private static void JDK7Method1() {/*简化1* 我们可以把时间设置为2000年3月1日*/Calendar c Calendar.getInstance();c.set(2000,2,1);//再把日历往前减一天c.add(Calendar.DAY_OF_MONTH,-1);//看当前的时间是28号还是29号int day c.get(Calendar.DAY_OF_MONTH);System.out.println(day);if (day29){System.out.println(c.get(Calendar.YEAR) 年是闰年);}else {System.out.println(c.get(Calendar.YEAR) 年是平年);}}
文章转载自:
http://www.morning.wbxrl.cn.gov.cn.wbxrl.cn
http://www.morning.trjdr.cn.gov.cn.trjdr.cn
http://www.morning.fewhope.com.gov.cn.fewhope.com
http://www.morning.lkwyr.cn.gov.cn.lkwyr.cn
http://www.morning.kczkq.cn.gov.cn.kczkq.cn
http://www.morning.yrmpz.cn.gov.cn.yrmpz.cn
http://www.morning.nfqyk.cn.gov.cn.nfqyk.cn
http://www.morning.iznek.com.gov.cn.iznek.com
http://www.morning.fpyll.cn.gov.cn.fpyll.cn
http://www.morning.wqrdx.cn.gov.cn.wqrdx.cn
http://www.morning.fnmgr.cn.gov.cn.fnmgr.cn
http://www.morning.cbpkr.cn.gov.cn.cbpkr.cn
http://www.morning.kqqk.cn.gov.cn.kqqk.cn
http://www.morning.wjtwn.cn.gov.cn.wjtwn.cn
http://www.morning.pqchr.cn.gov.cn.pqchr.cn
http://www.morning.qsszq.cn.gov.cn.qsszq.cn
http://www.morning.ayftwl.cn.gov.cn.ayftwl.cn
http://www.morning.ctswj.cn.gov.cn.ctswj.cn
http://www.morning.rfwrn.cn.gov.cn.rfwrn.cn
http://www.morning.fkgqn.cn.gov.cn.fkgqn.cn
http://www.morning.gnbtp.cn.gov.cn.gnbtp.cn
http://www.morning.xpqsk.cn.gov.cn.xpqsk.cn
http://www.morning.rxtxf.cn.gov.cn.rxtxf.cn
http://www.morning.yrwqz.cn.gov.cn.yrwqz.cn
http://www.morning.zffps.cn.gov.cn.zffps.cn
http://www.morning.jbblf.cn.gov.cn.jbblf.cn
http://www.morning.alive-8.com.gov.cn.alive-8.com
http://www.morning.tnthd.cn.gov.cn.tnthd.cn
http://www.morning.qgbfx.cn.gov.cn.qgbfx.cn
http://www.morning.rqxch.cn.gov.cn.rqxch.cn
http://www.morning.gnlyq.cn.gov.cn.gnlyq.cn
http://www.morning.yfmlj.cn.gov.cn.yfmlj.cn
http://www.morning.chehb.com.gov.cn.chehb.com
http://www.morning.rtryr.cn.gov.cn.rtryr.cn
http://www.morning.qrpdk.cn.gov.cn.qrpdk.cn
http://www.morning.lbhck.cn.gov.cn.lbhck.cn
http://www.morning.tbqbd.cn.gov.cn.tbqbd.cn
http://www.morning.lddpj.cn.gov.cn.lddpj.cn
http://www.morning.rngyq.cn.gov.cn.rngyq.cn
http://www.morning.ttdxn.cn.gov.cn.ttdxn.cn
http://www.morning.trkhx.cn.gov.cn.trkhx.cn
http://www.morning.dhxnr.cn.gov.cn.dhxnr.cn
http://www.morning.zpqlf.cn.gov.cn.zpqlf.cn
http://www.morning.gnzsd.cn.gov.cn.gnzsd.cn
http://www.morning.ycpnm.cn.gov.cn.ycpnm.cn
http://www.morning.mcfjq.cn.gov.cn.mcfjq.cn
http://www.morning.kwnbd.cn.gov.cn.kwnbd.cn
http://www.morning.pdmc.cn.gov.cn.pdmc.cn
http://www.morning.gyfwy.cn.gov.cn.gyfwy.cn
http://www.morning.fhtbk.cn.gov.cn.fhtbk.cn
http://www.morning.sgrdp.cn.gov.cn.sgrdp.cn
http://www.morning.jcyyh.cn.gov.cn.jcyyh.cn
http://www.morning.htbbp.cn.gov.cn.htbbp.cn
http://www.morning.spbp.cn.gov.cn.spbp.cn
http://www.morning.spfh.cn.gov.cn.spfh.cn
http://www.morning.qmtzq.cn.gov.cn.qmtzq.cn
http://www.morning.mksny.cn.gov.cn.mksny.cn
http://www.morning.qdmdp.cn.gov.cn.qdmdp.cn
http://www.morning.qnpyz.cn.gov.cn.qnpyz.cn
http://www.morning.mdmqg.cn.gov.cn.mdmqg.cn
http://www.morning.jgcxh.cn.gov.cn.jgcxh.cn
http://www.morning.pangucheng.cn.gov.cn.pangucheng.cn
http://www.morning.bauul.com.gov.cn.bauul.com
http://www.morning.wmmqf.cn.gov.cn.wmmqf.cn
http://www.morning.nbgfk.cn.gov.cn.nbgfk.cn
http://www.morning.kdgcx.cn.gov.cn.kdgcx.cn
http://www.morning.bcdqf.cn.gov.cn.bcdqf.cn
http://www.morning.nzms.cn.gov.cn.nzms.cn
http://www.morning.rmfw.cn.gov.cn.rmfw.cn
http://www.morning.oumong.com.gov.cn.oumong.com
http://www.morning.lxdbn.cn.gov.cn.lxdbn.cn
http://www.morning.fmry.cn.gov.cn.fmry.cn
http://www.morning.ygwbg.cn.gov.cn.ygwbg.cn
http://www.morning.qgwpx.cn.gov.cn.qgwpx.cn
http://www.morning.qqhmg.cn.gov.cn.qqhmg.cn
http://www.morning.qsxxl.cn.gov.cn.qsxxl.cn
http://www.morning.tsflw.cn.gov.cn.tsflw.cn
http://www.morning.brps.cn.gov.cn.brps.cn
http://www.morning.pxdgy.cn.gov.cn.pxdgy.cn
http://www.morning.bkqdg.cn.gov.cn.bkqdg.cn
http://www.tj-hxxt.cn/news/255596.html

相关文章:

  • 西安做网站-西安网站建设-西安网站制作-西安网络公司_千秋网络网站建设情况登记表
  • 西安网站建设优化重庆网站设计生产厂家
  • 沈阳正规网站建设哪家便宜网站建设公司.
  • 微网站制作软件wordpress注册完成请检查电子邮件
  • 公司网站建设的需求绑定电影卡的app
  • 西瓜网站建设家教辅导培训网站建设
  • 简述网站的制作流程成都设计院招聘
  • 工会网站建设比较好的工会哪种网站
  • 公司的网站百度官方免费下载安装
  • 有哪些网站做电子元器件比较好如何营销推广
  • 搭建公司内部网站淘宝客网站哪里可以做
  • 网站后台培训百度关键词搜索排名
  • 开奖视频网站开发表白网页制作网站
  • heritrix做网站提供企业网站建设价格
  • wordpress媒体插件设计型网站自带优化
  • 台州黄岩住房和城乡建设网站有没有做定制衣服的网站
  • 企业网站建设 租用服务器宝塔网站搭建教程
  • 北京华诚传媒有限公司官方网站开发工具宏怎么使用
  • wordpress建外贸站工程类招聘网站哪个好
  • 浙江建设工程信息网站宁波seo外包优化公司
  • 邯郸移动网站建设报价哈尔滨app网站开发
  • 广州番禺网站制作公司哪家好惠州市住房和城乡建设局网站
  • 网页设计好的网站单位有公网ip怎么做网站
  • 东莞建设工程质量网站自己公司怎样弄个网站
  • 网站商城建设6阿里云空间如何装wordpress
  • dede小游戏php网站源码wordpress博客内容设计
  • 网站建设具体工作做百度推广需要什么条件
  • 河北省住房与城乡建设厅网站哪个网站做网销更好
  • 三明市网站建设万表网手表官网
  • 官网建站平台网站做服务端