摘要: 上一篇博文说到了插入排序,如果我将内循环中的较大元素都向右移动,而不是总是两两之间进行交换。这个把较大元素不断上浮的算法就是大家经常说的冒泡排序 1 public class BubbleSort 2 { 3 public static void sort(int[] a) 4 { ... 阅读全文
posted @ 2014-05-15 21:23 owen-beta 阅读(211) 评论(0) 推荐(0) 编辑
摘要: public class InsertSort{ public static void sort(int[] a) { int N = a.length; int count = 0; for (int i = 1; i 0; j--) { if (a[j] < a[j-1]) ... 阅读全文
posted @ 2014-05-15 21:16 owen-beta 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 1 public class SlectedSort 2 { 3 public static void sort(int[] a) 4 { 5 int N = a.length; 6 for (int i = 0; i < N; i++) 7 ... 阅读全文
posted @ 2014-05-14 23:31 owen-beta 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 18.public class Test{ public static void add3(Integer i) { int val=i.intvalue(); val+=3; i=new Integer(val); } ... 阅读全文
posted @ 2014-05-05 15:32 owen-beta 阅读(319) 评论(0) 推荐(0) 编辑
摘要: 14. which three are valid declaraction of a float? ADFA. float foo=-1; B. float foo=1.0; C. float foo=42e1; D. float foo=2.02f; E. float foo=3.03d; F.... 阅读全文
posted @ 2014-05-05 11:06 owen-beta 阅读(765) 评论(0) 推荐(0) 编辑
摘要: 11. what is reserved words in java?A. run B. default C. implement D. import Java 中,给标识符取名的时候,不能使用关键字和保留字。在 Java 中常用的关键字有: 1、访问控制符: public、protecte... 阅读全文
posted @ 2014-05-01 19:57 owen-beta 阅读(351) 评论(0) 推荐(0) 编辑
摘要: 3.public class IfTest{ public static void main(String args[]){ int x=3; int y=1; if(x=y) System.out.println("Not eq... 阅读全文
posted @ 2014-04-30 21:46 owen-beta 阅读(290) 评论(0) 推荐(0) 编辑
摘要: 1.1) public class ReturnIt{2) returnType methodA(byte x, double y){3) return (short)x/y*2;4) }5) }what is valid returnType for methodA in line 2?这... 阅读全文
posted @ 2014-04-30 20:48 owen-beta 阅读(410) 评论(0) 推荐(0) 编辑
摘要: 内容:鸡兔同笼中头的总数,脚的总数,求鸡兔各多少只输入说明:一行两个整数分别表示头、脚总数(保证有解,当然有可能解为0)输出说明:一行两个整数,分别表示鸡、兔的只数输入样例:20 40 输出样例 :20 0 1 #include 2 int main(void) 3 { 4 int head, foot; 5 scanf("%d %d", &head, &foot); 6 int ji, tu; 7 /* 8 4x + 2y = foot 9 2x + 2y = 2head10 x = (foot - 2head... 阅读全文
posted @ 2014-02-16 10:51 owen-beta 阅读(280) 评论(0) 推荐(0) 编辑
摘要: 内容:输出图形*****$***$$$*$$$$$规律是...自己发现吧。要求输入3,输出上面三行的图形输入说明:行数小于40输出说明:输入样例:3输出样例 :*****$ ***$$$*$$$$$ 1 #include 2 int main(void) 3 { 4 int n; 5 scanf("%d", &n); 6 /* 7 n = 3 8 * $ 9 ---10 5 111 3 312 1 513 14 n = 415 * $16 ---17 7 118 5 319 3 5... 阅读全文
posted @ 2014-02-16 10:46 owen-beta 阅读(422) 评论(0) 推荐(0) 编辑