package com
.yimu
.test
;
@SuppressWarnings("all")
public class Test01 {
public static String
spinWords(String sentence
) {
String temp
;
String str
;
int j
=0;
StringBuilder stringBuilder
= new StringBuilder();
String
[] s
= sentence
.split(" ");
if(s
.length
>1){
for (String s1
: s
) {
if(s1
.length()>=5){
String
[] s2
= s1
.split("");
for (int i
= 0; i
< s2
.length
/2; i
++) {
temp
= s2
[i
];
s2
[i
] = s2
[s2
.length
-1-i
];
s2
[s2
.length
-1-i
]=temp
;
}
for (String s3
: s2
) {
stringBuilder
.append(s3
);
}
if(s
.length
==j
+1){
}else{
stringBuilder
.append(" ");
}
}else if(s1
.length()>0){
stringBuilder
.append(s1
);
if(s
.length
==j
+1){
}else{
stringBuilder
.append(" ");
}
}
j
++;
}
str
= stringBuilder
.toString();
return str
;
}else {
if (sentence
.length()>= 5) {
String
[] st
= sentence
.split("");
for (int i
= 0; i
< st
.length
/ 2; i
++) {
temp
= st
[i
];
st
[i
] = st
[st
.length
- 1 - i
];
st
[st
.length
- 1 - i
] = temp
;
}
for (String s1
: st
) {
stringBuilder
.append(s1
);
}
str
=stringBuilder
.toString();
return str
;
}else{
str
=sentence
;
return str
;
}
}
}
public static void main(String
[] args
) {
String s
= spinWords("This is a test");
System
.out
.println(s
);
}
}
package com
.yimu
.test
;
public class Test02 {
public static String
high(String s
) {
String str
= "";
int flag
= 0;
String
[] s1
= s
.split(" ");
for (String s2
: s1
) {
String
[] split
= s2
.split("");
int i
= 0;
for (String word
: split
) {
for (int j
= 1; j
< 27 ; j
++) {
if (word
.hashCode() == (96+j
)) {
i
+=j
;
}
}
}
if (i
> flag
) {
flag
= i
;
str
= s2
;
}
}
return str
;
}
public static void main(String
[] args
) {
String s
= high("");
System
.out
.println(s
);
}
}
package com
.yimu
.test
;
public class Test03 {
public static char findMissingLetter(char[] array
){
char ch
= ' ';
StringBuilder stringBuilder
= new StringBuilder();
for (char c
: array
) {
stringBuilder
.append(c
);
}
String s
= stringBuilder
.toString();
String
[] split
= s
.split("");
int i
= split
[0].hashCode();
int j
= 0;
for (String s1
: split
) {
if (s1
.hashCode() != i
) {
ch
= (char) (j
+ 1);
return ch
;
}
i
+=1;
j
= s1
.hashCode();
}
return ch
;
}
public static void main(String
[] args
) {
char[] str
= {'O','Q','R','S'};
char c
= findMissingLetter(str
);
System
.out
.println("结果"+c
);
}
}
package com
.yimu
.test
;
public class Test04 {
public static String oddOrEven
(int[] array
) {
int sum
= 0;
String str
= null
;
if (array
== null
) {
str
="even";
}
for (int i
: array
) {
sum
+=i
;
}
if (sum
%2==0) {
str
="even";
}else {
str
="odd";
}
return str
;
}
public static void main(String
[] args
) {
int[] ints
= {};
String s
= oddOrEven(ints
);
System
.out
.println(s
);
}
}
package com
.yimu
.test
;
public class Test05 {
public static int sortDesc(final int num
) {
String s
= String
.valueOf(num
);
String
[] split
= s
.split("");
int[] ints
= new int[split
.length
];
int i
= 0;
int temp
= 0;
for (String s1
: split
) {
ints
[i
] = Integer
.parseInt(s1
);
i
+=1;
}
for (int j
= 0; j
< ints
.length
; j
++) {
for (int k
= 0; k
< ints
.length
-j
-1; k
++) {
if (ints
[k
]<ints
[k
+1]) {
temp
=ints
[k
];
ints
[k
]=ints
[k
+1];
ints
[k
+1]=temp
;
}
}
}
StringBuilder stringBuilder
= new StringBuilder();
for (int anInt
: ints
) {
stringBuilder
.append(anInt
);
}
int i1
= Integer
.parseInt(stringBuilder
.toString());
return i1
;
}
public static void main(String
[] args
) {
int i
= sortDesc(1912345);
System
.out
.println(i
);
}
}