题目 /*You are a professional robber planning to rob houses along a street. * Each house has a certain amount of money stashed, * the only constraint stopping you from robbing each of them is that * adjacent houses have security system connected and *…
1.给数组做反序 public class Ak01 { public static void main(String[] args) { int[] a = new int[]{22,48,41,2,7,9}; int start=0; int end=a.length-1; int size = a.length; for(int i = 0;i<size/2;i++) { int temp; temp = a[start]; a[start]=a[end]; a[end]=temp; st…
题目:判断101-200之间有多少个素数,并输出所有素数. 思路:判断素数的方法:用一个数分别去除2到sqrt(这个数),如果能被整除,则表明此数不是素数,反之是素数. 具体代码: public Vector exp(int first, int end) { Vector v = new Vector(); boolean b; for (int i = first; i <= end; i++) { b = true;// 假设是质数 for (int j = 2; j < i; j++)…
1.下面输出结果是什么? public class Test { public static void main(String[] args) { Person person=new Person("张三"); change(person); System.out.println(person.name); } public static void change(Person person) { Person person2=new Person("李四"); pe…