Advertisement
netpeti98HU

C# sorbarendezes

Jan 10th, 2014
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using System;
  2.  
  3.   class Program
  4.     {
  5.         static void Main(string[] args)
  6.         {
  7.  
  8.             int[] tomb = new int[10];
  9.             Random r = new Random();
  10.  
  11.             for (int i = 0; i < tomb.Length; ++i)
  12.             {
  13.                 tomb[i] = r.Next(100);
  14.                 Console.Write(tomb[i] + " ");
  15.             }
  16.             Console.WriteLine();
  17.  
  18.             //Rendezes
  19.  
  20.             for (int a = 0; a < tomb.Length; ++a)
  21.             {
  22.  
  23.                 for (int b = 0; b < tomb.Length; ++b)
  24.                 {
  25.  
  26.                     if (tomb[b] > tomb[a])
  27.                     {
  28.                         int c = tomb[a];
  29.                         tomb[a] = tomb[b];
  30.                         tomb[b] = c;
  31.                     }
  32.  
  33.                 }
  34.  
  35.             }
  36.        
  37.             for (int i = 0; i < tomb.Length; ++i)
  38.             {
  39.                 Console.Write(tomb[i] + " ");
  40.             }
  41.  
  42.  
  43.             Console.ReadLine();
  44.         }
  45.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement