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

邯郸手机网站建设报价如何做网站外部链接

邯郸手机网站建设报价,如何做网站外部链接,抖音seo搜索优化,西安到北京西火车时刻表本文是在学习过C语言后#xff0c;开始进行Java学习时#xff0c;对于基本语法的一些案例练习。案例内容来自B站黑马编程课 1.HelloWorld 问题介绍;请编写程序输出“HelloWorld”. public class HelloWorld { public static void main(String[] args) { System.out.print…       本文是在学习过C语言后开始进行Java学习时对于基本语法的一些案例练习。案例内容来自B站黑马编程课 1.HelloWorld 问题介绍;请编写程序输出“HelloWorld”. public class HelloWorld { public static void main(String[] args) { System.out.println(Hello World); } } 1. public class HelloWorld :公共类Public Class),每个Java源文件中都可以有一个且只有一个公共类这个公共类的名称必须与源文件的名称相同包括大小写。 2.main(String [ ] args): 类中包含了一个主方法main方法这是Java程序的入口点。main方法接受一个字符串数组args作为参数这个数组通常用于接收从命令行传递给程序的参数。 3.println:在main方法内部调用了System.out.println方法来在控制台上打印出字符串Hello World。System.out是Java的标准输出流而println是一个方法用于输出数据并换行。 2.购买飞机票 问题介绍用户购买机票时机票原价会按照淡季旺季头等舱还是经济舱的情况进行相应的优惠优惠方案如下5-10月为旺季头等舱9折经济舱8.5折11月到来年4月为淡季头等舱7折经济舱6.5折请开发程序计算用户当前机票的优惠价。 package JAVA_study.src.Text;import java.util.Scanner;public class Text1 {public static void main(String[] age){Scanner sr new Scanner(System.in);double money 1000.0; //票价System.out .println(请输入当前月份);int month sr.nextInt();System.out.println(请输入选择机票种类);String type sr.next();double place sed(money,month,type);System.out.println(最终票价为 place);}public static double sed(double money,int month,String type){double place 1.0;if(month 5 month 10){switch (type) {case 头等舱 : place 0.9 * money; break;case 经济舱 : place 0.85 * money;break;}}else {switch (type) {case 头等舱 : place 0.7 * money; break;case 经济舱 : place 0.65 * money; break;}}return place;} } 1.方法类似于c中的函数 2.选择语句和判断语句 对于ifelse if以及Switch case 语句和C语言用法是一致的。 3.生成验证码 问题介绍开发一个程序可以生成指定位数的验证码每位可以是数字大小写字母。 package JAVA_study.src.Text;import java.util.Random; import java.util.Scanner;public class Text2 {public static void main(String[] args){Scanner sr new Scanner(System.in);int length sr.nextInt();System.out.println(code(length));}public static String code(int n){Random r new Random();String ans ;for(int i0;in;i){int type r.nextInt(3);switch (type) {case 0: ans r.nextInt(10);break;case 1: char str1 (char)(r.nextInt(26)65); ans str1;break;case 2: char str2 (char)(r.nextInt(26)6532); ans str2;break;}}return ans;} } 1.随机数函数Random使用Random(3)生成从0-2的三位随机数即包含左边不包含右边。 4.评委打分 问题介绍在唱歌比赛中可能有多个评委要给选手打分分数是[0 -100] 之间的整数。选手最后的得分为去掉最高分最低分后剩余分数的平均分请编写程序能够录入多名评委的分数并计算选手的最终得分。 package JAVA_study.src.Text;import java.util.Scanner;public class Text3 {public static void main(String[] arr){Scanner se new Scanner(System.in);System.out.println(请输入评委人数);int num se.nextInt();System.out.println(该学生的成绩为A(num)分);}public static double A(int num){Scanner se new Scanner(System.in);double ave 0.0;int MAX 0;int MIN 100;int sum 0;int[] sums new int [num];for(int i0;inum;i){System.out.println(请输入第(i1)位评委的分数);int sr se.nextInt();sums[i] sr;sum sr;if(sr MAX){MAX sr;}if(sr MIN){MIN sr;}}ave (sum-MAX-MIN)/(num-2.0);return ave;} } //这是没有看视频之前自己写的下面是视频代码 /* import java.util.Scanner;public class Text3 {public static void main(String[] arr){Scanner se new Scanner(System.in);System.out.println(请输入评委人数);int num se.nextInt();System.out.println(该学生的成绩为A(num)分);}public static double A(int num){Scanner se new Scanner(System.in);double ave 0.0;int MAX 0;int MIN 100;int sum 0;int[] sums new int [num];for(int i0;inum;i){System.out.println(请输入第(i1)位评委的分数);int sr se.nextInt();sums[i] sr;sum sr;if(sr MAX){MAX sr;}if(sr MIN){MIN sr;}}ave (sum-MAX-MIN)/(num-2.0);return ave;} }*/package JAVA_study.src.Text;import java.util.Scanner;public class Text3 {public static void main(String[] arr) {//目标完成评委打分案例System.out.println(当前选手的得分是getAverageScore(6));}public static double getAverageScore(int number){//定义一个动态初始化的数组方便后期存入评委的打分int []scores new int [number];//遍历数组每一个位置依次录入评委分数Scanner sc new Scanner(System.in);for (int i 0;inumber;i) {System.out.println(请您录入第(i1)个评委的分数);int score sc.nextInt();scores[i] score;}int sum 0; //求总分的变量int max scores[0];int min scores[0];//遍历一般找数据for (int i 0; i scores.length; i) {int score scores[i];sum score;if(score max){max score;}if(score min){min score;}}return (sum-min-max)/(number-2.0);} } 1.for循环与C语言使用是一致的for(循环变量;终止条件;变量变化){ 执行语句;} 在IDEA中可以使用 循环的次数.fori回车来快捷输入一个for循环。 2.数据运算包括四则运算自增自减运算都和C语言是一致的还有浮点数除法除数要加小数点。 5.数字解密 问题介绍某系统的数字密码是一个四位数如1983为了安全需要加密后再传输加密规则是对于密码的每位数都加5再对10求余最后将所有的数字顺序反转得到一组加密后的新数请设计出满足本需求的加密程序。 package JAVA_study.src.Text;import java.util.Scanner;public class Text4 {public static void main(String [] ages){Scanner sc new Scanner(System.in);System.out.println(请输入要加密的数字);int num sc.nextInt();int number 1;int s num;while(s 1){number;ss/10;}int [] a M(num,number);int result 0;int p 1;for (int i number-1; i 0; i--) {result a[i]*p;p *10;}System.out.println(result);}public static int [] M(int num,int number){int [] arrs new int[number];for (int i 0; i number; i) {arrs[i] ((num%10)5)%10;num num/10;}return arrs;} } 1.Java可以直接返回数组基本的计算方法与C语言是一致的这里没有参考视频中的函数写法。 6.数组拷贝 问题介绍请把一个整型数组例如存储了数据11,22,33拷贝成一个新数组出来 package JAVA_study.src.Text;import java.util.Arrays; import java.util.Scanner;public class Text5 {public static void main(String []ags){System.out.println(请输入数组元素个数);Scanner sc new Scanner(System.in);int number sc.nextInt();int [] arr new int [number];for (int i 0; i number; i) {System.out.println(请输入第(i1)个数组元素);int input sc.nextInt();arr[i] input;}int [] result Copy_arr(arr,number);for(int i0;inumber;i){System.out.println(result[i]); }}public static int []Copy_arr(int []arr,int number){int []new_arr new int [number];for (int i 0; i number; i) {new_arr[i] arr[i];}return new_arr;} } java提供了许多简单有用的函数来实现一些功能。 1.数组打印除开for循环外提供了一种System.out.println(Arrays.toString(result))的实现方法。这行代码的作用是打印数组result的内容到控制台每个元素以字符串形式表示元素之间用逗号加空格分隔整个数组被方括号包围。 2.数组拷贝可以不用手动循环拷贝可以使用System.arraycopy(arr, 0new_arr, 0, number) 关于arraycopy函数 参数解释 arrObject src源数组即你要从中复制数据的数组。0int srcPos源数组中的起始位置索引从该位置开始复制数据。在这个例子中它是 0意味着从源数组的第一个元素开始复制。new_arrObject dest目标数组即你要将数据复制进去的数组。这个数组必须已经存在并且有足够的空间来存储要复制的数据。0int destPos目标数组中的起始位置索引从该位置开始放置复制的数据。在这个例子中它也是 0意味着从目标数组的第一个元素开始放置数据。numberint length要复制的数组元素的数量。在这里number 指定了从源数组复制到目标数组的元素数量。 操作过程 System.arraycopy 方法会从 arr 数组的 0 索引位置开始复制 number 个元素到 new_arr 数组的 0 索引位置。 如果 new_arr 数组的长度小于 number那么将会抛出 ArrayIndexOutOfBoundsException 异常因为目标数组没有足够的空间来存储所有要复制的元素。 如果源数组 arr 的长度小于 srcPos length在这个例子中是 0 number那么同样会抛出 ArrayIndexOutOfBoundsException 异常因为源数组没有足够的元素可供复制。 注意事项 在使用 System.arraycopy 之前确保目标数组 new_arr 已经被正确初始化并且有足够的空间来存储要复制的数据。如果源数组和目标数组是同一个数组并且源位置和目标位置有重叠那么复制的结果将是未定义的。对于基本数据类型数组和对象数组System.arraycopy 都可以正常工作。但是对于对象数组复制的是对象的引用而不是对象本身。 7.抢红包 问题介绍一个大V直播时发起了抢红包活动分别有9.666.188.520.99999五个红包。请模拟粉丝来抽奖按照先来先得随机抽取抽完为止注意一个红包只能抽一次先抽或后抽哪一个红包时随机的。 package JAVA_study.src.Text;import java.util.Random; import java.util.Scanner;public class Text6 {public static void main(String [] args){//目标:完成抢红包案列的开发int []moneys {9,666,188,520,99999};start(moneys);}public static void start(int []moneys){Scanner sc new Scanner(System.in);Random r new Random();for (int i 0; i 5; i) {System.out.println(请输入任意内容进行抽奖);sc.next(); //等待输入内容按到回车才往下走while(true) {int index r.nextInt(moneys.length);int money moneys[index];if (money ! 0) {System.out.println(恭喜您您抽中了红包 money);moneys[index] 0;break;}}}System.out.println(活动结束);} } 8.找素数 问题介绍判断101-200之间有多少个素数并输出所有素数 package JAVA_study.src.Text;import java.util.Arrays;public class Text7 {public static void main(String[] args){su();}public static void su(){//目标是从101到200之间的素数int sum;int num 0;int [] result new int [100];int input 0;for (int i 101; i 200; i) {sum 0;for (int i1 2; i1 i; i1) {if(i%i1 0){sum;}}if(sum 0){result[input] i;num;}}System.out.println(共有素数num个);for (int i 0; i num; i) {System.out.println(result[i] );}}} 教学中提供的是信号位思想。使用flat来进行判断。 for (int i 101; i 200; i) {boolean flat true;for (int i1 2; i1 i; i1) {if(i%i1 0){flat false;}}if(flat){result[input] i;num;}} 9.打印九九乘法表 问题介绍 打印九九乘法表 public class MultiplicationTable { public static void main(String[] args) { // 外层循环控制行 for (int i 1; i 9; i) { // 内层循环控制列 for (int j 1; j i; j) { // 打印乘法表的一项注意这里j和i的顺序决定了是横向打印还是纵向打印 System.out.print(j * i (i * j) \t); } // 每完成一行的打印后输出一个换行符以开始新的一行 System.out.println(); } } } 10.模拟双色球 问题介绍用户投注7个号码6个红色1个蓝色。按照和系统随机出的这组号码判断中奖金额。 package JAVA_study.src.Text;import java.util.Arrays; import java.util.Random; import java.util.Scanner;public class Text8 {public static void main(String[] args) {int [] a1 inputarr();System.out.println(Arrays.toString(a1));int [] a2 suijiarr();System.out.println(Arrays.toString(a2));cmp(a1,a2);}public static int[] inputarr() {int[] arr new int[7];Scanner sc new Scanner(System.in);for (int i 0; i 6; i) {while (true) {System.out.println(请输入第 (i 1) 位红球号码);int num sc.nextInt();if (num 1 || num 33) {System.out.println(号码有误 请检查);} else {if (exist(arr, num)) {System.out.println(输入的号码重复 请重试);} else {arr[i] num;break;}}}}while (true) {System.out.println(请输入蓝球号码);int num sc.nextInt();if (num 1 || num 16) {System.out.println(号码有误 请检查);} else {arr[6] num;break;}}return arr;}public static int[] suijiarr() {int[] arr new int[7];Random r new Random();for (int i 0; i 6; i) {while (true) {int n r.nextInt(33)1;if (!exist(arr, n)) {arr[i] n;break;}}}while (true) {int n r.nextInt(17)1;if (!exist(arr, n)) {arr[6] n;break;}}return arr;}private static boolean exist( int[] arr, int num){for (int i 0; i 7; i) {if(arr[i] 0){break;}if (arr[i] num) {return true;}}return false;}public static void cmp(int []a1,int []a2){int redcount0,bluecount0;for (int i 0; i 6; i) {for (int j 0; j 6; j) {if(a1[i] a2[j]){redcount ;break;}}}if(a1[6] a2[6]){bluecount;}switch(redcount){case 6:if(bluecount 1){System.out.println(恭喜您中奖 1000万元);break;}else{System.out.println(恭喜您中奖 500万元);break;}case 5:if(bluecount 1){System.out.println(恭喜您中奖 3000元);break;}else{System.out.println(恭喜您中奖 200元);break;}case 4:if(bluecount 1){System.out.println(恭喜您中奖 200元);break;}else{System.out.println(恭喜您中奖 10元);break;}case 3:if(bluecount 1){System.out.println(恭喜您中奖 10元);break;}else{System.out.println(恭喜您中奖 5元);break;}case 2:if(bluecount 1){System.out.println(恭喜您中奖 5元);break;}case 1:if(bluecount 1){System.out.println(恭喜您中奖 5元);break;}case 0:if(bluecount 1){System.out.println(恭喜您中奖 5元);break;}System.out.println(很遗憾 您没有中奖);break;}}}
文章转载自:
http://www.morning.zsgbt.cn.gov.cn.zsgbt.cn
http://www.morning.tlrxt.cn.gov.cn.tlrxt.cn
http://www.morning.bktly.cn.gov.cn.bktly.cn
http://www.morning.ctfh.cn.gov.cn.ctfh.cn
http://www.morning.jbpodhb.cn.gov.cn.jbpodhb.cn
http://www.morning.bgpch.cn.gov.cn.bgpch.cn
http://www.morning.cnprt.cn.gov.cn.cnprt.cn
http://www.morning.lwzpp.cn.gov.cn.lwzpp.cn
http://www.morning.nlgmr.cn.gov.cn.nlgmr.cn
http://www.morning.yltyz.cn.gov.cn.yltyz.cn
http://www.morning.wgbmj.cn.gov.cn.wgbmj.cn
http://www.morning.jcypk.cn.gov.cn.jcypk.cn
http://www.morning.ncfky.cn.gov.cn.ncfky.cn
http://www.morning.lgmgn.cn.gov.cn.lgmgn.cn
http://www.morning.trsmb.cn.gov.cn.trsmb.cn
http://www.morning.ytbr.cn.gov.cn.ytbr.cn
http://www.morning.dpsgq.cn.gov.cn.dpsgq.cn
http://www.morning.c7617.cn.gov.cn.c7617.cn
http://www.morning.grtwn.cn.gov.cn.grtwn.cn
http://www.morning.rjyd.cn.gov.cn.rjyd.cn
http://www.morning.kycwt.cn.gov.cn.kycwt.cn
http://www.morning.fnpmf.cn.gov.cn.fnpmf.cn
http://www.morning.cwrnr.cn.gov.cn.cwrnr.cn
http://www.morning.ohmyjiu.com.gov.cn.ohmyjiu.com
http://www.morning.plfy.cn.gov.cn.plfy.cn
http://www.morning.jmnfh.cn.gov.cn.jmnfh.cn
http://www.morning.bcngs.cn.gov.cn.bcngs.cn
http://www.morning.wchcx.cn.gov.cn.wchcx.cn
http://www.morning.lysrt.cn.gov.cn.lysrt.cn
http://www.morning.ffbl.cn.gov.cn.ffbl.cn
http://www.morning.rhkq.cn.gov.cn.rhkq.cn
http://www.morning.wfysn.cn.gov.cn.wfysn.cn
http://www.morning.mttqp.cn.gov.cn.mttqp.cn
http://www.morning.zgqysw.cn.gov.cn.zgqysw.cn
http://www.morning.zrks.cn.gov.cn.zrks.cn
http://www.morning.pzrnf.cn.gov.cn.pzrnf.cn
http://www.morning.txnqh.cn.gov.cn.txnqh.cn
http://www.morning.rwmft.cn.gov.cn.rwmft.cn
http://www.morning.ptwqf.cn.gov.cn.ptwqf.cn
http://www.morning.ckcjq.cn.gov.cn.ckcjq.cn
http://www.morning.hxlch.cn.gov.cn.hxlch.cn
http://www.morning.xhpnp.cn.gov.cn.xhpnp.cn
http://www.morning.drmbh.cn.gov.cn.drmbh.cn
http://www.morning.rtryr.cn.gov.cn.rtryr.cn
http://www.morning.xsfny.cn.gov.cn.xsfny.cn
http://www.morning.cxtbh.cn.gov.cn.cxtbh.cn
http://www.morning.gnbtp.cn.gov.cn.gnbtp.cn
http://www.morning.drggr.cn.gov.cn.drggr.cn
http://www.morning.wmsgt.cn.gov.cn.wmsgt.cn
http://www.morning.rtbj.cn.gov.cn.rtbj.cn
http://www.morning.xbdrc.cn.gov.cn.xbdrc.cn
http://www.morning.txmkx.cn.gov.cn.txmkx.cn
http://www.morning.tcfhs.cn.gov.cn.tcfhs.cn
http://www.morning.dpqwq.cn.gov.cn.dpqwq.cn
http://www.morning.kfbth.cn.gov.cn.kfbth.cn
http://www.morning.qnzpg.cn.gov.cn.qnzpg.cn
http://www.morning.fsrtm.cn.gov.cn.fsrtm.cn
http://www.morning.wpspf.cn.gov.cn.wpspf.cn
http://www.morning.qcdtzk.cn.gov.cn.qcdtzk.cn
http://www.morning.hlppp.cn.gov.cn.hlppp.cn
http://www.morning.mytmn.cn.gov.cn.mytmn.cn
http://www.morning.qdbcd.cn.gov.cn.qdbcd.cn
http://www.morning.nyqzz.cn.gov.cn.nyqzz.cn
http://www.morning.trqsm.cn.gov.cn.trqsm.cn
http://www.morning.fslxc.cn.gov.cn.fslxc.cn
http://www.morning.lhrwy.cn.gov.cn.lhrwy.cn
http://www.morning.lgmgn.cn.gov.cn.lgmgn.cn
http://www.morning.rhmpk.cn.gov.cn.rhmpk.cn
http://www.morning.plxhq.cn.gov.cn.plxhq.cn
http://www.morning.drswd.cn.gov.cn.drswd.cn
http://www.morning.rhfh.cn.gov.cn.rhfh.cn
http://www.morning.jpqmq.cn.gov.cn.jpqmq.cn
http://www.morning.mplld.cn.gov.cn.mplld.cn
http://www.morning.glxmf.cn.gov.cn.glxmf.cn
http://www.morning.zlhcw.cn.gov.cn.zlhcw.cn
http://www.morning.rwtlj.cn.gov.cn.rwtlj.cn
http://www.morning.ymjrg.cn.gov.cn.ymjrg.cn
http://www.morning.ccsdx.cn.gov.cn.ccsdx.cn
http://www.morning.nlbhj.cn.gov.cn.nlbhj.cn
http://www.morning.yrmpr.cn.gov.cn.yrmpr.cn
http://www.tj-hxxt.cn/news/245416.html

相关文章:

  • 网站建设 外包是什么意思可信赖的坪山网站建设
  • 湖北seo网站推广WordPress 动漫源码
  • 电商网站平台有哪些广州短视频运营培训
  • 工作室暴利项目南京网站优化方案
  • 建手机wap网站大概多少钱长沙室内设计学校
  • vps如何创建网站公众号平台app
  • 自己做免费手机网站吗网站建设服务那一个便宜
  • 做一般的公司门户网站投资额本科毕业设计代做网站
  • 资源下载类网站源码做淘客网站用什么程序
  • 网站服务器提供什么服务网络营销带来的效果
  • 网站建设公司销售招聘电子商务网站与建设课件
  • 大连网站建设设计公司哪家好wordpress配置搜索引擎优化
  • 出版社网站建设方案关键词优化排名软件哪家好
  • 做网站 公司 个体模版型网站
  • 多米诺网站建设中国交通建设网官方网站
  • 龙岗网站建设短视频投放方案
  • 秦皇岛网站制作电话婚纱摄影东莞网站建设技术支持
  • wordpress建站版本推荐微平台网站开发
  • 网站策划书的要点一朋友做网站网站被抓了
  • 德邦公司网站建设特点网页广告图片
  • nodejs做网站能保护源代码吗山东建筑公司实力排名
  • 手机网站经典案例微信带颜色的公众号
  • 网站建设基础知识怎么做网站搜索
  • 网页好看的网站设计网站死链处理
  • 中山大学精品课程网站山东省工程建设信息网
  • 做图海报网站网站建设管理ppt
  • php商业网站制作快速网站仿制
  • 怎么对自己做的网站进行加密论坛是做网站还是app好
  • vue做网站的好处wordpress菜单不现实
  • 网站做弹幕广告网站版式设计说明