Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main(string[] args)
- {
- int[] tomb = new int[10]; Random r = new Random();
- tomb[0] = 2; tomb[1] = 1; tomb[2] = 3; tomb[3] = 4; tomb[4] = 5; tomb[5] = 6; tomb[6] = 7; tomb[7] = 8; tomb[8] = 9; tomb[9] = 10;
- //Rendezes
- int szamlalo = 0;
- for (int a = 0; a < tomb.Length; ++a)
- {
- for (int b = 0; b < tomb.Length; ++b)
- {
- if (tomb[b] > tomb[a])
- {
- szamlalo++;
- int c = tomb[a];
- tomb[a] = tomb[b];
- tomb[b] = c;
- }
- }
- }
- for (int i = 0; i < tomb.Length; ++i)
- {
- Console.Write(tomb[i] + " ");
- }
- Console.WriteLine("\n" + szamlalo);
- Console.ReadLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement