Advertisement
Shailrshah

Descending Sorting of Strings with First 3 chars Deleted

Oct 30th, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1. import java.util.Scanner;
  2. class DelThree{
  3.     public static void main(String[] args){
  4.         Scanner sc = new Scanner(System.in);
  5.         String[] a = new String[5];
  6.         int i, j;
  7.         for(i = 0; i < 5; i++){
  8.             System.out.print("Enter a String: ");
  9.             a[i] = sc.nextLine();
  10.             a[i] = a[i].substring(3,a[i].length());
  11.         }
  12.         for(i = 1; i<a.length; i++){
  13.             String temp = a[i];
  14.             for(j = i-1; j>=0 && temp.compareToIgnoreCase(a[j])>0; j--) a[j+1] = a[j];
  15.             a[j+1] = temp;
  16.         }
  17.         for(i = 0; i < 5; i++) System.out.println(a[i]);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement