All pastes #2120937 Raw Edit

Someone

public text v1 · immutable
#2120937 ·published 2012-02-23 01:33 UTC
rendered paste body
import java.util.Scanner;
import java.io.*;

public class Main {
  public static void main(String[] args) throws FileNotFoundException {
    int type, order, data, all;
    int count=0;
        
    Scanner scan= new Scanner (System.in);
    Scanner file = new Scanner (new File ("set.txt"));   
        
    IntegerType[] num = new IntegerType[2000];
        
    for(int i = 0; i<num.length; i++) {
      System.out.flush();
      num[i]=new IntegerType(file.nextInt());
      System.out.flush();
    }
    
    System.out.println("3 for ascending ints: 4 for desending ints: 0 for choice");
    all=scan.nextInt();

    if(all==3) {
      Sorts.insertionSortA(num);
      Sorts.shellSortA(num);	        
      Sorts.mergeSortA(num);	        	        
      Sorts.bubbleSortA(num);
      Sorts.selectionSortA(num);      
    } else if(all==4) {
      Sorts.mergeSortD(num);
      Sorts.bubbleSortD(num);
      Sorts.selectionSortD(num);
      Sorts.insertionSortD(num);		        
      Sorts.shellSortD(num);
    } else if(all==0) {
      System.out.println("data type");
      System.out.println("(1: integer; 2: string)");
      data = scan.nextInt();

      System.out.println("sort type");
      System.out.println("(1: bubble; 2: selection; 3: insertion; 4: merge; 5: shell)");
      type = scan.nextInt();

      System.out.println("order type");
      System.out.println("(1: acsending; 2: descending)");
      order = scan.nextInt();

      if(data==1) {
        if(type==1) {
          if(order==1) Sorts.bubbleSortA(num);
          else if (order==2) Sorts.bubbleSortD(num);
          else System.out.println("Invalid");
        } else if(type==2) {
          if(order==1) Sorts.selectionSortA(num);
          else if (order==2) Sorts.selectionSortD(num);
          else System.out.println("Invalid");
        } else if(type==3) {
          if(order==1) Sorts.selectionSortA(num);
          else if (order==2) Sorts.selectionSortD(num);
          else System.out.println("Invalid");
        } else if(type==4) {
          if(order==1) Sorts.mergeSortA(num);
          else if (order==2) Sorts.mergeSortD(num);
          else System.out.println("Invalid");
        } else if(type==5) {
          if(order==1) Sorts.shellSortA(num);
          else if (order==2) Sorts.shellSortD(num);
          else System.out.println("Invalid");
        }
      }
    }
  }
}