Advertisement
Asphorm

Daniel

Jun 18th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3.  
  4. public class DeinKlassenName {
  5. public static void main(String[] args) {
  6.  
  7. try {
  8. File file1 = new File("daten_org.txt");
  9. File file2 = new File("daten_sort.txt");
  10. File file3 = new File("array_1.txt"); //die hilfsdateien bitte umbenennen
  11. File file4 = new File("array_2.txt");
  12. file2.createNewFile();
  13. file3.createNewFile();
  14. file4.createNewFile();
  15.  
  16. Scanner scanner = new Scanner(file1);
  17. Scanner scr1 = new Scanner(file3); //benenne die scanner bitte noch um
  18. Scanner scr2 = new Scanner(file4);
  19.  
  20. PrintStream prs = new PrintStream(file2);
  21. PrintStream prs1 = new PrintStream(file3); //und die printstreams
  22. PrintStream prs2 = new PrintStream(file4);
  23.  
  24. int[] arr = new int[100];
  25.  
  26. for(int i = 0; i < 100; i++) {
  27. arr[i] = scanner.nextInt();
  28. }
  29. DeinQuicksort(arr)
  30. for(int i = 0; i < 100; i++) {
  31. prs1.print(arr[i] + " ");
  32. }
  33. Arrays.fill(arr, 2147483647);
  34. for(int i = 100; i < 165; i++) {
  35. arr[i-100] = scanner.nextInt();
  36. }
  37. DeinQuicksort(arr)
  38. for(int i = 100; i < 165; i++) {
  39. prs2.print(arr[i-100] + " ");
  40. }
  41.  
  42. int a = 0, b = 0;
  43. int z1 = 0, z2 = 0;
  44. boolean bA = true, bB = true;
  45.  
  46. for(int i = 0; i < 165; i++) {
  47. if(bA && scr1.hasNextInt()) a = scr1.nextInt();
  48. if(bB && scr2.hasNextInt()) b = scr2.nextInt();
  49.  
  50. if(z1 < 100 && z2 < 65) {
  51. if(a < b) {
  52. prs.print(a + " ");
  53. bA = true;
  54. bB = false;
  55. z1++;
  56. }
  57. if(a > b) {
  58. prs.print(b + " ");
  59. bA = false;
  60. bB = true;
  61. z2++;
  62. }
  63. if(a == b) {
  64. prs.print(a + " " + b + " ");
  65. bA = true;
  66. bB = true;
  67. i++;
  68. z1++; z2++;
  69. }
  70. } else {
  71. if(z1 == 100) {
  72. while(scr2.hasNextInt()) {
  73. prs.print(scr2.nextInt() + " ");
  74. }
  75. }
  76. if(z2 == 65) {
  77. while(scr1.hasNextInt()) {
  78. prs.print(scr1.nextInt() + " ");
  79. }
  80. }
  81. }
  82.  
  83.  
  84.  
  85. }
  86.  
  87.  
  88. prs.close();
  89. prs1.close();
  90. prs2.close();
  91. } catch (IOException e) {}
  92.  
  93. System.out.println();
  94. System.out.println("Deine Ausgabe");
  95. }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement