@nabbit123/

Project#15c

Java

No description

fork
loading
Files
  • Main.java

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.9082426070349772","path":"Main.java","file":{"path":"Main.java","content":{"asEncoding":{"base64":"aW1wb3J0IGphdmEudXRpbC4qOwpjbGFzcyBNYWluIHsKICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICBpbnQgYzsKICAgIEFycmF5TGlzdDxJbnRlZ2VyPiBhcnJheT1uZXcgQXJyYXlMaXN0PEludGVnZXI+KCk7CiAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkRlZmF1bHQiKTsKICAgIGZvcihpbnQgeD0wOyB4IDwgNTsgeCsrKXsKICAgICAgICBhcnJheS5hZGQoKGludCkoNDAqTWF0aC5yYW5kb20oKSsxKSk7CiAgICB9CiAgICBmb3IgKGludCBpID0gMDsgaSA8IDU7IGkrKyl7CiAgICAgIFN5c3RlbS5vdXQucHJpbnQoYXJyYXkuZ2V0KGkpICsgIiAiKTsKICAgIH0KICAgIGludCBuPTA7CgkJd2hpbGUobiE9NCkgewoJCQlmb3IoaW50IGE9MDthPDQ7YSsrKSB7CgkJCQlmb3IoaW50IGI9MTtiPDU7YisrKSB7CgkJCQkJaWYoYSE9YikgewoJCQkJCQlpZihhcnJheS5nZXQoYSkgPT0gYXJyYXkuZ2V0KGIpKSB7CgkJCQkJCQlhcnJheS5yZW1vdmUoYXJyYXkuZ2V0KGEpKTsKCQkJCQkJCWFycmF5LmFkZCgoaW50KSg0MCpNYXRoLnJhbmRvbSgpKzEpKTsKICAgICAgICAgICAgfQoJCQkJCX0KCQkJCX0KCQkJfQoJCQluKys7CiAgICAgIH0KICAgIFN5c3RlbS5vdXQucHJpbnRsbigpOwogICAgU3lzdGVtLm91dC5wcmludGxuKCJTb3J0ZWQiKTsKICAgIGJ1YmJsZVNvcnQoYXJyYXkpOwogICAgZm9yKGM9MDtjPDU7YysrKXsKICAgICAgU3lzdGVtLm91dC5wcmludChhcnJheS5nZXQoYykrIiAiKTsKICAgIH0KICAgIH0KICBwdWJsaWMgc3RhdGljIHZvaWQgYnViYmxlU29ydChBcnJheUxpc3Q8SW50ZWdlcj4gbGlzdCkgewogICAgaW50IG4gPSBsaXN0LnNpemUoKTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbiAtIDE7IGkrKykgewogICAgICBmb3IgKGludCBqID0gMDsgaiA8IG4gLSBpIC0gMTsgaisrKSB7CiAgICAgICAgaWYgKGxpc3QuZ2V0KGopID4gbGlzdC5nZXQoaisxKSkgewogICAgICAgICAgaW50IHRlbXAgPSBsaXN0LmdldChqKTsKICAgICAgICAgIGxpc3Quc2V0KGosbGlzdC5nZXQoaisxKSk7CiAgICAgICAgICBsaXN0LnNldChqKzEsdGVtcCk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgfQp9"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import java.util.*;
class Main {
  public static void main(String[] args) {
    int c;
    ArrayList<Integer> array=new ArrayList<Integer>();
    System.out.println("Default");
    for(int x=0; x < 5; x++){
        array.add((int)(40*Math.random()+1));
    }
    for (int i = 0; i < 5; i++){
      System.out.print(array.get(i) + " ");
    }
    int n=0;
		while(n!=4) {
			for(int a=0;a<4;a++) {
				for(int b=1;b<5;b++) {
					if(a!=b) {
						if(array.get(a) == array.get(b)) {
							array.remove(array.get(a));
							array.add((int)(40*Math.random()+1));
            }
					}
				}
			}
			n++;
      }
    System.out.println();
    System.out.println("Sorted");
    bubbleSort(array);
    for(c=0;c<5;c++){
      System.out.print(array.get(c)+" ");
    }
    }
  public static void bubbleSort(ArrayList<Integer> list) {
    int n = list.size();
    for (int i = 0; i < n - 1; i++) {
      for (int j = 0; j < n - i - 1; j++) {
        if (list.get(j) > list.get(j+1)) {
          int temp = list.get(j);
          list.set(j,list.get(j+1));
          list.set(j+1,temp);
        }
      }
    }
  }
}