Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int[] zufall;
- zufall = new int[20];
- Random rn = new Random();
- for (int i = 0; i < zufall.Length; i++)
- {
- zufall[i] = rn.Next(-100, 100);
- }
- //Ausgabe des Arrays
- Console.WriteLine("[{0}]", string.Join(", ", zufall));
- //maximum bestimmen
- int max = zufall[0]; //1. Wert merken
- for (int i = 1; i < zufall.Length; i++)
- {
- if(max < zufall[i])
- {
- max = zufall[i];
- }
- }
- //minimum bestimmen
- int min = zufall[0]; //1. Wert merken
- for (int i = 1; i < zufall.Length; i++)
- {
- if (zufall[i] < min)
- {
- min = zufall[i];
- }
- }
- Console.WriteLine();
- // Ausgabe des Maximums
- Console.WriteLine("Die größte zahl ist: {0}.", max);
- Console.WriteLine("Die kleinste zahl ist: {0}.", min);
- Console.WriteLine();
- //int[] zufall;
- //zufall = new int[20];
- //Random rn = new Random();
- //int[] zufall;
- //zufall = new int[20];
- //Random rn = new Random();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement