
练习
imyyn
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
欧几里得算法、幂运算。
欧几里得算法 public static long gcd(long m, long n) { while (n != 0) { long rem = m % n; m = n; n = rem; } return m; }幂运算 public...原创 2019-06-17 13:27:43 · 332 阅读 · 0 评论 -
折半查找。
/* 折半查找 */class Test { public static void main(String[] args) { int[] a = new int[100]; for (int i = 0; i < 100; i++) a[i] = i; System.out.println(binarySe...原创 2019-06-17 11:29:50 · 251 阅读 · 0 评论 -
编写带有下列声明的例程。
/* 编写带有下列声明的例程:public void permute(String str);public void permute(char[] str, int low, int high); */class Z_Pra_1_6 { public static void main(String[] args) { String str = "abc"; ...原创 2019-06-11 14:02:40 · 784 阅读 · 0 评论 -
编写一个递归方法,它返回数N的二进制表示中1的个数。
/* 编写一个递归方法,它返回数N的二进制表示中1的个数。 */class Z_Pra_1_5 { public static void main(String[] args) { int num = 12121; System.out.println(Integer.toBinaryString(num)); System.out.pr...原创 2019-06-11 12:23:35 · 469 阅读 · 0 评论 -
最大子序列和问题的求解。
递归、“分治”策略时间复杂度为:O(NlogN)/* 最大子序列和问题的求解。 */class Test { public static void main(String[] args) { int a[] = { 1, 2, -1, 2, -4, -10, 7, -1, -9, 4, 2, -3, 5, -9 }; System.out.pri...原创 2019-06-16 21:19:51 · 282 阅读 · 0 评论 -
只使用处理I/O的PrintDigit方法,编写一种方法以输出任意double型值。
import java.util.Scanner;/* 只使用处理I/O的PrintDigit方法,编写一种方法以输出任意double型值(可以是负的)。 */class Z_Pra_1_3 { public static void main(String[] args) { double n; Scanner input = new Scanner...原创 2019-06-11 11:11:40 · 1484 阅读 · 0 评论 -
编写一个程序求解字谜游戏问题。
/* 编写一个程序求解字谜游戏问题。 */class Z_Pra_1_2{ public static final String[] WORDS={"this","two","fat","that"}; public static final char[][] ziMi={{'t','h','i','s'},{'w','a','t','s'},{'o','a','h','g'}...原创 2019-06-07 18:58:25 · 1889 阅读 · 1 评论 -
java 中缀表达式到后缀表达式的转换。
import java.util.Scanner;import java.util.Stack;class Test { public static void main(String[] args) { String expression = ""; Scanner input = new Scanner(System.in); exp...原创 2019-07-04 13:33:06 · 269 阅读 · 0 评论