Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Assignment;
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- public class main {
- public static void main(String[] args) {
- try {
- BufferedReader reader = new BufferedReader(new FileReader("/Users/niloykumarkundu/Desktop/Socket/src/Assignment/input.txt"));
- int[] arr = new int[100];
- String input;
- int i = 0;
- while((input = reader.readLine()) != null) {
- String[] list = input.split(",");
- for(String x : list) {
- arr[i++] = Integer.parseInt(x);
- }
- }
- for(int j = 0; j < i; j++) {
- for(int k = j; k < i; k++) {
- if(arr[j] < arr[k]) {
- int temp = arr[j];
- arr[j] = arr[k];
- arr[k] = temp;
- }
- }
- }
- for(int j = 0; j < i; j++) {
- if(j == i - 1) {
- System.out.println(arr[j]);
- } else {
- System.out.print(arr[j] + ",");
- }
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement