-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTexicOrder.java
More file actions
47 lines (39 loc) · 1.14 KB
/
Copy pathTexicOrder.java
File metadata and controls
47 lines (39 loc) · 1.14 KB
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
public class TexicOrder {
public static void main (String[] args) {
char[] a = {'a', 'b', 'c'};
char[] b = {'a', 'd', 'c'};
System.out.println(texicOrder(a, b));
a = new char[]{'a', 'b', 'c'};
b = null;
System.out.println(texicOrder(a, b));
a = new char[]{'a', 'b', 'c'};
b = new char[]{'a', 'b', 'c'};
System.out.println(texicOrder(a, b));
a = new char[]{'a', 'b', 'c', 'f'};
b = new char[]{'a', 'b', 'c'};
System.out.println(texicOrder(a, b));
a = new char[]{'a', 'b', 'f'};
b = new char[]{'a', 'b', 'd', 'c'};
System.out.println(texicOrder(a, b));
a = new char[]{'a', 'b', 'f'};
b = new char[]{'a', 'b', 'g', 'c'};
System.out.println(texicOrder(a, b));
a = new char[]{'a', 'b', 'f'};
b = new char[]{'a', 'g'};
System.out.println(texicOrder(a, b));
}
static int texicOrder (char[] a, char[] b) {
if (a == null || b == null)
return 3;
for (int i = 0; i < a.length && i < b.length; i++) {
if (a[i] > b[i])
return 1;
else if (a[i] < b[i])
return 2;
}
if (a.length >= b.length)
return 1;
else
return 2;
}
}