Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. package com.company;
  2.  
  3. public class Main {
  4. public Main() {
  5. }
  6.  
  7. public static void main(String[] args) {
  8. int N_MIN = true;
  9. int N_MAX = true;
  10. int N = true;
  11. boolean kopie = false;
  12. short geloescht = 0;
  13. short[] ganzzahlen = new short[100];
  14. short[] geordnet = new short[100];
  15.  
  16. int x;
  17. int k;
  18. for(x = 0; x < 100; ++x) {
  19. ganzzahlen[x] = (short)((int)(Math.random() * 100.0D + 1.0D));
  20.  
  21. for(k = 0; k < x; ++k) {
  22. if (ganzzahlen[x] == ganzzahlen[k]) {
  23. kopie = true;
  24. break;
  25. }
  26. }
  27.  
  28. if (!kopie) {
  29. geordnet[x] = ganzzahlen[x];
  30. } else {
  31. ++geloescht;
  32. }
  33.  
  34. System.out.println(ganzzahlen[x] + " " + geordnet[x]);
  35. kopie = false;
  36. }
  37.  
  38. System.out.println();
  39.  
  40. for(x = 0; x < 100; ++x) {
  41. k = 0;
  42.  
  43. while(geordnet[x] == 0) {
  44. for(int y = x; y < 99; ++y) {
  45. geordnet[y] = geordnet[y + 1];
  46. k += geordnet[y];
  47. }
  48.  
  49. if (k == 0) {
  50. break;
  51. }
  52. }
  53. }
  54.  
  55. System.out.println();
  56. short[] gekuerzt = new short[100 - geloescht];
  57.  
  58. for(k = 0; k < 100 - geloescht; ++k) {
  59. gekuerzt[k] = geordnet[k];
  60. System.out.println(gekuerzt[k]);
  61. }
  62.  
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement