Advertisement
Guest User

ilość_kuponów

a guest
Nov 18th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp9
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Random generator = new Random();
  14.  
  15.             int[] tablica = new int[6];
  16.             int tmp;
  17.  
  18.             Console.Write("Podaj liczbę kuponów ");
  19.             int ile_kuponow = Convert.ToInt16(Console.ReadLine()), k;
  20.  
  21.             for (k = 1; k <= ile_kuponow; k++)
  22.             {
  23.  
  24.                 for (int i = 0; i < tablica.Length; i++)
  25.                 {
  26.  
  27.                     tablica[i] = generator.Next(1, 50);
  28.  
  29.                     for (int j = 0; j < i; j++)
  30.                     {
  31.                         if (tablica[i] == tablica[j]) i--;
  32.  
  33.                     }
  34.                 }
  35.  
  36.                 foreach (int posortowane in tablica)
  37.                 {
  38.                     for (int i = 0; i < tablica.Length - 1; i++)
  39.                     {
  40.  
  41.  
  42.  
  43.                         if (tablica[i] > tablica[i + 1])
  44.                         {
  45.                             tmp = tablica[i];
  46.                             tablica[i] = tablica[i + 1];
  47.                             tablica[i + 1] = tmp;
  48.                         }
  49.                     }
  50.                 }
  51.                 foreach (int losowa in tablica)
  52.                 {
  53.                     Console.Write("{0}\t", losowa);
  54.                 }
  55.                 Console.WriteLine();
  56.                
  57.             }
  58.  
  59.             Console.ReadKey();
  60.  
  61.         }
  62.  
  63.  
  64.  
  65.        
  66.  
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement