package chapter7;import java.io.File;import java.io.FileNotFoundException;import java.io.PrintStream;import java.util.Scanner;public class demo4 { public static void main(String[] args) { int s[]=new int[100]; try { Scanner sc=new Scanner(new File("score1.txt")); PrintStream out=new PrintStream(new File("score2.txt")); for(int i=0;i<100;i++) { if(sc.hasNextInt()) { int score=sc.nextInt(); s[i]=score; } } for(int i=0;i<100;i++) { for(int j=i+1;j<100;j++) { if(s[i]>s[j]) { int temp=s[j]; s[j]=s[i]; s[i]=temp; } } } for(int i=0;i<100;i++) { if(s[i]==0) { continue; }else { out.print(s[i]+" "); } } out.close(); sc.close(); }catch(FileNotFoundException e) { System.out.println("file not found"); }catch(Exception e) { System.out.println("error"); } }}