Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- public class DeinKlassenName {
- public static void main(String[] args) {
- try {
- File file1 = new File("daten_org.txt");
- File file2 = new File("daten_sort.txt");
- File file3 = new File("array_1.txt"); //die hilfsdateien bitte umbenennen
- File file4 = new File("array_2.txt");
- file2.createNewFile();
- file3.createNewFile();
- file4.createNewFile();
- Scanner scanner = new Scanner(file1);
- Scanner scr1 = new Scanner(file3); //benenne die scanner bitte noch um
- Scanner scr2 = new Scanner(file4);
- PrintStream prs = new PrintStream(file2);
- PrintStream prs1 = new PrintStream(file3); //und die printstreams
- PrintStream prs2 = new PrintStream(file4);
- int[] arr = new int[100];
- for(int i = 0; i < 100; i++) {
- arr[i] = scanner.nextInt();
- }
- DeinQuicksort(arr)
- for(int i = 0; i < 100; i++) {
- prs1.print(arr[i] + " ");
- }
- Arrays.fill(arr, 2147483647);
- for(int i = 100; i < 165; i++) {
- arr[i-100] = scanner.nextInt();
- }
- DeinQuicksort(arr)
- for(int i = 100; i < 165; i++) {
- prs2.print(arr[i-100] + " ");
- }
- int a = 0, b = 0;
- int z1 = 0, z2 = 0;
- boolean bA = true, bB = true;
- for(int i = 0; i < 165; i++) {
- if(bA && scr1.hasNextInt()) a = scr1.nextInt();
- if(bB && scr2.hasNextInt()) b = scr2.nextInt();
- if(z1 < 100 && z2 < 65) {
- if(a < b) {
- prs.print(a + " ");
- bA = true;
- bB = false;
- z1++;
- }
- if(a > b) {
- prs.print(b + " ");
- bA = false;
- bB = true;
- z2++;
- }
- if(a == b) {
- prs.print(a + " " + b + " ");
- bA = true;
- bB = true;
- i++;
- z1++; z2++;
- }
- } else {
- if(z1 == 100) {
- while(scr2.hasNextInt()) {
- prs.print(scr2.nextInt() + " ");
- }
- }
- if(z2 == 65) {
- while(scr1.hasNextInt()) {
- prs.print(scr1.nextInt() + " ");
- }
- }
- }
- }
- prs.close();
- prs1.close();
- prs2.close();
- } catch (IOException e) {}
- System.out.println();
- System.out.println("Deine Ausgabe");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement