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
package test; //遍历输出 public class BaseSort { public void sort(int[] a){ for (int i: a) { System.out.print(i + " "); } System.out.println(); } } package test; public class Factory { private BaseSort sort; public void setSort(BaseSort sort){ this.sort = sort; } public void doSort(int[] a){ sort.sort(a); } } package test; //未完成 public class InsertSort extends BaseSort { } package test; //未完成 public class QuickSort extends BaseSort{ } package test; //选择排序 public class SelectSort extends BaseSort{ public void sort(int[] a){ int temp; for (int i = 0; i < a.length - 1; i++) { for (int j = i+1; j < a.length; j++) { if(a[i] < a[j]){ temp = a[j]; a[j] = a[i]; a[i] = temp; } } } BaseSort show = new BaseSort(); show.sort(a); } } //以下为主函数 package test; import java.util.Scanner; public class test { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[] num = new int[n]; for (int i = 0; i < n; i++) { num[i] = scanner.nextInt(); } Factory factory = new Factory(); BaseSort selectsort = new SelectSort(); factory.setSort(selectsort); factory.doSort(num); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
!未完成!插入排序,快速排序未完成
The text was updated successfully, but these errors were encountered: