摘要:
二分法的逻辑思想为: public static void main(String[] args) { int a[]={1,3,5,7,9,11}; int end=a.length;//数组的结束位置+1 int b=2; boolean isFind=false; for (int begin 阅读全文
摘要:
import java.util.Arrays; public class Prac02 { public static void main(String[] args) { int num=(int)((Math.random()*9000)+1000); for (int i = 0; i <7 阅读全文
摘要:
百钱买白鸡的逻辑相对简单,只需要知道公鸡母鸡小鸡每种最多能买多少,最少要买多少。 然后三种鸡的数目相加为一百,总价为一百,即可得到结果。 此处公鸡2元,母鸡1元,小鸡五毛。 public class Prac02 { public static void main(String[] args) { 阅读全文
摘要:
冒泡排序的思路是用数组中一个值和其他值挨个比较,使用循环控制对比。 这里要设置两个循环,外层循环用于控制数组中作比较的值,内层循环用于控制这个作比较的值和其他值对比。 插旗则可以看成一个条件判断,满足条件则执行。 //冒泡排序和插旗 public class Demo04 { public stat 阅读全文