Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- public class Testes {
- public static void main(String[] args) throws Exception {
- Scanner input = new Scanner(new File("file.txt"));
- int idx = 0;
- while (input.hasNextInt()) {
- idx ++;
- input.nextInt();
- }
- input.close();
- input = new Scanner(new File("file.txt"));
- int[] vec = new int[idx];
- for(int i = 0; input.hasNextInt(); ++i) {
- vec[i] = input.nextInt();
- }
- for (int i = 0; i < vec.length; i++) {
- int aux = -1;
- for (int j = 0; j < vec.length - 1; j++) {
- if (vec[j] > vec[j + 1]) {
- aux = vec[j];
- vec[j] = vec[j + 1];
- vec[j + 1] = aux;
- }
- }
- }
- for (int i = 0; i < vec.length; ++i) {
- System.out.println("" + vec[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment