We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
代码如下:
public class FastSort{ public static void main(String []args){ System.out.println("Hello World"); int[] a = {12,20,5,16,15,1,30,45,23,9}; int start = 0; int end = a.length-1; sort(a,start,end); for(int i = 0; i<a.length; i++){ System.out.println(a[i]); } } public void sort(int[] a,int low,int high){ int start = low; int end = high; int key = a[low]; while(end>start){ //从后往前比较 while(end>start&&a[end]>=key) //如果没有比关键值小的,比较下一个,直到有比关键值小的交换位置,然后又从前往后比较 end--; if(a[end]<=key){ int temp = a[end]; a[end] = a[start]; a[start] = temp; } //从前往后比较 while(end>start&&a[start]<=key)//如果没有比关键值大的,比较下一个,直到有比关键值大的交换位置 start++; if(a[start]>=key){ int temp = a[start]; a[start] = a[end]; a[end] = temp; } //此时第一次循环比较结束,关键值的位置已经确定了。左边的值都比关键值小,右边的值都比关键值大,但是两边的顺序还有可能是不一样的,进行下面的递归调用 } //递归 if(start>low) sort(a,low,start-1);//左边序列。第一个索引位置到关键值索引-1 if(end<high) sort(a,end+1,high);//右边序列。从关键值索引+1到最后一个 } }
效果不理想:
public class DOS外部命令从标准输入设备接收数据{ public static void 主群组(String []args){ System.out.println("Hello World"); int[] a = {12,20,5,16,15,1,30,45,23,9}; int start = 0; int end = a.length-1; sort(a,start,end); for(int i = 0; i<a.length; i++){ System.out.println(a[i]); } } public void sort(int[] a,int low,int high){ int start = low; int end = high; int key = a[low]; while(end>start){ //从后往前比较 while(end>start&&a[end]>=key) //如果没有比关键值小的,比较下一个,直到有比关键值小的交换位置,然后又从前往后比较 end--; if(a[end]<=key){ int temp = a[end]; a[end] = a[start]; a[start] = temp; } //从前往后比较 while(end>start&&a[start]<=key)//如果没有比关键值大的,比较下一个,直到有比关键值大的交换位置 start++; if(a[start]>=key){ int temp = a[start]; a[start] = a[end]; a[end] = temp; } //此时第一次循环比较结束,关键值的位置已经确定了。左边的值都比关键值小,右边的值都比关键值大,但是两边的顺序还有可能是不一样的,进行下面的递归调用 } //递归 if(start>low) sort(a,low,start-1);//左边序列。第一个索引位置到关键值索引-1 if(end<high) sort(a,end+1,high);//右边序列。从关键值索引+1到最后一个 } }
首要问题:
public void sort(int[] a,int low,int high)
另外, 明显需要翻译方法内容
The text was updated successfully, but these errors were encountered:
首要问题解决: program-in-chinese/java_code_translator@a7584d0
关于方法内容, 如代码翻译尝试-使用Roaster解析和生成Java源码所言: Roaster还不支持对方法内容的解析
一种可能: 用Antlr4分析方法, 还需尝试.
Sorry, something went wrong.
No branches or pull requests
代码如下:
效果不理想:
首要问题:
public void sort(int[] a,int low,int high)
未翻译另外, 明显需要翻译方法内容
The text was updated successfully, but these errors were encountered: