added diffrent finished codes
This commit is contained in:
parent
0596844f83
commit
d3092e64bf
4 changed files with 66 additions and 0 deletions
BIN
bin/Archiv/Sort.class
Normal file
BIN
bin/Archiv/Sort.class
Normal file
Binary file not shown.
BIN
bin/Archiv/exchange.class
Normal file
BIN
bin/Archiv/exchange.class
Normal file
Binary file not shown.
33
src/Archiv/Sort.java
Normal file
33
src/Archiv/Sort.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
package Archiv;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Sort {
|
||||
public static void main(String[] args) throws Exception {
|
||||
// Creating a Random object
|
||||
Random random = new Random();
|
||||
|
||||
// Define the range for variables
|
||||
int minRange = -10000;
|
||||
int maxRange = 10000;
|
||||
|
||||
// Generate random values
|
||||
int a = random.nextInt(maxRange - minRange + 1) + minRange;
|
||||
int b = random.nextInt(maxRange - minRange + 1) + minRange;
|
||||
int c = random.nextInt(maxRange - minRange + 1) + minRange;
|
||||
|
||||
System.out.println("a equals:" + a);
|
||||
System.out.println("b equals:" + b);
|
||||
System.out.println("c equals:" + c);
|
||||
|
||||
if (a > b && a > c) {
|
||||
System.out.println("The largest variable is: a");
|
||||
} else if (b > a && b > c) {
|
||||
System.out.println("The largest variable is: b");
|
||||
} else if (c > a && c > b) {
|
||||
System.out.println("The largest variable is: c");
|
||||
} else
|
||||
System.out.println("All variables have the same value");
|
||||
|
||||
}
|
||||
}
|
33
src/Archiv/exchange.java
Normal file
33
src/Archiv/exchange.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
package Archiv;
|
||||
|
||||
public class exchange {
|
||||
public static void main(String[] args) {
|
||||
|
||||
int x = 5;
|
||||
int y = 7;
|
||||
|
||||
// Vor dem Tausch
|
||||
System.out.println(x);
|
||||
System.out.println(y);
|
||||
|
||||
// Tausch
|
||||
int z = 0;
|
||||
z = x;
|
||||
x = y;
|
||||
y = z;
|
||||
|
||||
// Nach dem Tausch
|
||||
System.out.println(x);
|
||||
System.out.println(y);
|
||||
|
||||
/*
|
||||
* Tauschen Sie die Inhalte der beiden Variablen! D. h.: Wenn vor dem
|
||||
* Tausch x den Wert 5 hatte und y den Wert 7, dann soll x nach dem
|
||||
* Tausch den Wert 7 haben und y den Wert 5. Führen Sie den Tausch
|
||||
* so durch, dass der Tausch funktioniert, egal mit welchen Werten x
|
||||
* und y initialisiert wurden.
|
||||
* Sie dürfen nur Code zwischen den beiden Kommentaren //Tausch
|
||||
* und //Nach dem Tausch hinzufügen!
|
||||
*/
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue