package util;
public class Line3 {
private static int n;
public static void tool(char a[]) {
int i=0;
char v;
int to;
int from;
for (i = 0; i < a.length; i++) {
v = a[a.length - 1];
to = a.length - 1 ;
from=i;
while(to>from) {
a[to] = a[to-1];
to--;
}
a[i]=v;
}
}
public static void main(String[] args) {
char[] c = {'1','2','3','4' ,'5'};
System.out.println(c);
tool(c);
System.out.println(c);
}
}
这个代码想了好几天,终于弄懂了排序的规律,希望能继续写出与目标意思相近的代码
注重思维
-2019.8.4
晚上 22:50