⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 comparison.java

📁 sorting,分类的几种常见的java实现
💻 JAVA
字号:
package sorting_yanrui;

import java.util.Random;
import java.util.Scanner;


public class Comparison {
static InsertSorting insert;
static HeapSorting heap;
static QuickSorting quick;
static ShellSorting shell;

public void main(String []args)
{  System.out.println("Input the number of digits to be sorted");
Scanner sc = new Scanner(System.in);
int i = sc.nextInt();
  int[] a = null;
  for(int j=0;j<i;j++)
  {Random rand = new Random();
    a[j]= rand.nextInt(i); 
    }
  int length=a.length;
    long t1=insert.insertSorting(a,length);
    long t2=heap.heapsort(a, length);
    long t3=quick.QuickSorting(a, 0, length-1);
    long t4=shell.shellsort(a, length);
    System.out.println("The time cost of insertsorting is"+t1);
    System.out.println("The time cost of heapsorting is"+t2);
    System.out.println("The time cost of quicksorting is"+t3);
    System.out.println("The time cost of shellsorting is"+t4);
  
  
}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -