Advertisement
Guest User

Untitled

a guest
Jan 10th, 2014
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. int szamlalo = 0;
  2.             int[] konyvek = new int[10] { 7, 10, 1, 3, 2, 8, 4, 9, 6, 5};
  3.             for (int a = 0; a < konyvek.Length-1; ++a)
  4.             {
  5.                 for (int b = a+1; b < konyvek.Length; ++b)
  6.                 {
  7.                     if (konyvek[b] < konyvek[a])
  8.                     {
  9.                    
  10.                        szamlalo++;
  11.                         int c = konyvek[a];
  12.                         konyvek[a] = konyvek[b];
  13.                         konyvek[b] = c;
  14.                         for (int i = 0; i < 10; i++)
  15.                         {
  16.                             Console.Write(" {0}",konyvek[i]);
  17.                         }
  18.                         Console.WriteLine();
  19.                     }
  20.                 }
  21.             }
  22.             Console.WriteLine(szamlalo);
  23.             Console.ReadKey();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement