Skip to content
New issue

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

removed #24

Open
xmmmmmovo opened this issue Nov 24, 2017 · 0 comments
Open

removed #24

xmmmmmovo opened this issue Nov 24, 2017 · 0 comments

Comments

@xmmmmmovo
Copy link

xmmmmmovo commented Nov 24, 2017

!未完成!插入排序,快速排序未完成


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);

    }
}
@xmmmmmovo xmmmmmovo changed the title 1707004539 马骕駸 removed Jan 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant