2016年5月16日

摘要: // 利用条件运算符的嵌套来完成此题:学习成绩> =90分的同学用A表示,60-89分之间的用B表示,60分以下的用C表示。 //求s=a+aa+aaa+aaaa+aa...a的值,其中a是一个数字。 //例如2+22+222+2222+22222(此时共有5个数相加),几个数相加由用户控制。 // 阅读全文
posted @ 2016-05-16 08:38 煜渝 阅读(228) 评论(0) 推荐(0) 编辑

2016年5月13日

摘要: String str = "asdfghjkl"; String str1 = "asd"; // 通过首位字母的索引比较 if (str.indexOf("asd") == 0) { System.out.println("true"); } String str2 = "jkl"; if (st 阅读全文
posted @ 2016-05-13 22:21 煜渝 阅读(1096) 评论(0) 推荐(0) 编辑
摘要: 1、 Java中值类型和引用类型的不同? [定义] 引用类型表示你操作的数据是同一个,也就是说当你传一个参数给另一个方法时,你在另一个方法中改变这个变量的值, 那么调用这个方法是传入的变量的值也将改变.值类型表示复制一个当前变量传给方法, 当你在这个方法中改变这个变量的值时,最初生命的变量的值不会变 阅读全文
posted @ 2016-05-13 21:54 煜渝 阅读(170) 评论(0) 推荐(0) 编辑
摘要: Random r=new Random(); int arr[]=new int [10]; for(int i=0;i<arr.length;i++) { arr[i]=r.nextInt(100); } System.out.println("随机生成的数组为:"); for(int j:arr 阅读全文
posted @ 2016-05-13 13:08 煜渝 阅读(171) 评论(0) 推荐(0) 编辑

2016年5月12日

摘要: String str="abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ0123456789"; Random r=new Random(); String arr[]=new String [4]; String b=""; for(int 阅读全文
posted @ 2016-05-12 21:49 煜渝 阅读(6155) 评论(0) 推荐(0) 编辑

2016年5月11日

摘要: Random r=new Random(); int a []=new int[6]; for (int i=0;i<a.length;i++) { int n=r.nextInt(36); a[i]=n+1; for(int j=0;j<i;j++) { if(a[i]==a[j]) { i=i- 阅读全文
posted @ 2016-05-11 13:51 煜渝 阅读(531) 评论(0) 推荐(0) 编辑
摘要: 方法1(数据类型)(最小值+Math.random()*(最大值-最小值+1))例:(int)(1+Math.random()*(10-1+1))从1到10的int型随数 方法2获得随机数for (int i=0;i<30;i++){System.out.println((int)(1+Math.r 阅读全文
posted @ 2016-05-11 10:10 煜渝 阅读(2409) 评论(0) 推荐(0) 编辑

2016年5月10日

摘要: int [] ary={9,5,7,-4,3,-2,10}; for (int i=0;i<ary.length;i++) { for (int j=i+1;j<ary.length;j++) { if(ary[i]<ary[j]) { int temp=ary[i]; ary[i]=ary[j]; 阅读全文
posted @ 2016-05-10 13:26 煜渝 阅读(138) 评论(0) 推荐(0) 编辑

2016年5月9日

摘要: double h=8848.13*1000; double z=0.08; int sum=0; for(int a=0;;a++) { z*=2; sum++; if(z>h) { break; } } System.out.println("需要对折"+sum+"次"); 阅读全文
posted @ 2016-05-09 14:08 煜渝 阅读(2834) 评论(0) 推荐(0) 编辑
摘要: double dn=0; double jc=1; for(int a=1;a<=20;a++) { jc*=a; dn=dn+1/jc; } System.out.println(dn); 阅读全文
posted @ 2016-05-09 13:15 煜渝 阅读(998) 评论(0) 推荐(0) 编辑

导航