有n个整数,使其前面各数顺序向后移m个位置,最后m个数变成最前面的m个数。 public class Example36 { public static void main(String[] args) { int[] m = { 18, 12, 23, 34, 95, 76, 57, 28, 9 Read More
posted @ 2017-06-08 14:14 本宫在,尔等都是妃 Views(320) Comments(1) Diggs(0) Edit
有一个数组,将其最大的元素与第一个元素交换,最小的元素与最后一个元素交换,然后输出数组。 public class Example35 { public static void main(String[] args) { int[] a = { 5, 7, 6, 1, 9, 4, 2, 3, 8 } Read More
posted @ 2017-06-07 10:43 本宫在,尔等都是妃 Views(146) Comments(0) Diggs(0) Edit
输入3个数a,b,c,按大小顺序输出。 public class Example34 { public static void main(String[] args) { sort(5, 20, 15); } public static void sort(int a, int b, int c) Read More
posted @ 2017-06-07 10:42 本宫在,尔等都是妃 Views(159) Comments(0) Diggs(0) Edit
打印出杨辉三角形(要求打印出10行如下图)11 11 2 11 3 3 11 4 6 4 11 5 10 10 5 1 public class Example33 { public static void main(String[] args) { yanghui(10); } public st Read More
posted @ 2017-06-07 10:41 本宫在,尔等都是妃 Views(187) Comments(0) Diggs(0) Edit
取一个整数a从右端开始的4~7位。 public class Example32 { public static void main(String[] args) { cut(123456789); } public static void cut(long n) { String s = Long Read More
posted @ 2017-06-07 10:40 本宫在,尔等都是妃 Views(122) Comments(0) Diggs(0) Edit
将一个数组逆序输出。 public class Example31 { public static void main(String[] args) { int[] a = { 9, 4, 6, 8, 3, 21, 16, 12 }; covertArray(a); } public static Read More
posted @ 2017-06-07 10:39 本宫在,尔等都是妃 Views(215) Comments(0) Diggs(0) Edit
有一个已经排好序的数组。现输入一个数,要求按原来的规律将它插入数组中。 public class Example30 { public static void main(String[] args) { int[] m = { 3, 5, 9, 12, 16, 20, 25, 33 }; addEl Read More
posted @ 2017-06-06 11:59 本宫在,尔等都是妃 Views(205) Comments(0) Diggs(0) Edit
求一个3*3矩阵对角线元素之和。 public class Example29 { public static void main(String[] args) { int[][] a = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; sum(a); } pu Read More
posted @ 2017-06-06 11:58 本宫在,尔等都是妃 Views(145) Comments(0) Diggs(0) Edit
对10个数进行排序。 public class Example28 { public static void main(String[] args) { int[] s = { 5, 7, 6, 1, 9, 4, 2, 3, 8 }; BubbleSort(s); } public static v Read More
posted @ 2017-06-06 11:57 本宫在,尔等都是妃 Views(116) Comments(0) Diggs(0) Edit
求100之内的素数。 public class Example27 { public static void main(String[] args) { prime(); } public static void prime() { System.out.print(2 + "\t"); Syste Read More
posted @ 2017-06-06 11:56 本宫在,尔等都是妃 Views(125) Comments(0) Diggs(0) Edit