为什么80%的码农都做不了架构师?>>>
复制代码
参考: [1].
http://blog.csdn.net/yuan22003/article/details/6779622
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.duapp.itfanr; public class CharDemo { public static void main(String args[]) { int input1[] = { 3, 6, 1, 9, 7 }; int input2[] = { 3, 6, 1, 9, 7, 8 }; // int len = input1.length ; // bubbleSort(input1); // sort(input1, len , output) ; int len = input2.length; int[] output = new int[len]; bubbleSort(input2); sort(input2, len, output); for (int i = 0; i < len; i++) System.out.println(output[i]); } static void sort(int input[], int n, int output[]) { int middle; if (n % 2 == 1) { middle = (n - 1) / 2; } else { middle = n / 2; } output[middle] = input[0]; int i = 1, j = 1, ii = 1; while (true) { if (ii == n) break; else { output[middle - i] = input[ii]; i++; ii++; if (ii == n) break; else output[middle + j] = input[ii]; j++; ii++; } } } static void bubbleSort(int input[]) { int len = input.length; for (int i = 1; i < len; i++) { for (int j = 0; j < len - i; j++) { if (input[j] < input[j + 1]) { int temp = input[j]; input[j] = input[j + 1]; input[j + 1] = temp; } } } } }
转载于:https://my.oschina.net/itfanr/blog/358434
最后
以上就是清爽朋友最近收集整理的关于java 华为机试题目-数组处理的全部内容,更多相关java内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复