Advertisement
abasar

9/11

Sep 11th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.96 KB | None | 0 0
  1. //#1
  2. using System;
  3. //using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using Unit4.BucketLib;
  7.  
  8. namespace ConsoleApplication1
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             Bucket[] buckets = new Bucket[6];
  15.             for (int i = 0; i < buckets.Length; i++)
  16.                 buckets[i] = new Bucket(50, i.ToString());
  17.            
  18.             double ammount = 50.0;
  19.  
  20.             for (int i = 0; i < buckets.Length; i++)
  21.             {
  22.                 buckets[i].Fill(ammount);
  23.                 ammount /= 2.0;
  24.             }
  25.         }
  26.     }
  27. }
  28.  
  29. //2
  30. using System;
  31. //using System.Collections.Generic;
  32. using System.Linq;
  33. using System.Text;
  34. using Unit4.BucketLib;
  35.  
  36. namespace ConsoleApplication1
  37. {
  38.     class Program
  39.     {
  40.         static void Main(string[] args)
  41.         {
  42.             int n = int.Parse(Console.ReadLine());
  43.             Bucket[] buckets = new Bucket[n];
  44.             for (int i = 0; i < buckets.Length; i++)
  45.                 buckets[i] = new Bucket(20, i.ToString());
  46.            
  47.            
  48.             Random rng = new Random();
  49.             double max = 0;
  50.             for (int i = 0; i < buckets.Length; i++)
  51.             {
  52.                 double randomNum = (double)rng.Next(21);
  53.                 if (randomNum > max)
  54.                     max = randomNum;
  55.                 buckets[i].Fill(randomNum);
  56.             }
  57.             for (int i = 0; i < buckets.Length; i++)
  58.                 buckets[i].Fill(max - buckets[i].GetCurrentAmount());
  59.  
  60.            
  61.         }
  62.     }
  63. }
  64.  
  65. //#3
  66. using System;
  67. //using System.Collections.Generic;
  68. using System.Linq;
  69. using System.Text;
  70. using Unit4.BucketLib;
  71.  
  72. namespace ConsoleApplication1
  73. {
  74.     class Program
  75.     {
  76.         static void Main(string[] args)
  77.         {
  78.             int n = int.Parse(Console.ReadLine());
  79.             Bucket[] buckets = new Bucket[n];
  80.             int[] ammounts = new int[n];
  81.             Random rng = new Random();
  82.  
  83.             for (int i = 0; i < buckets.Length; i++)
  84.                 buckets[i] = new Bucket(rng.Next(11), i.ToString());
  85.  
  86.             for (int i = 0; i < buckets.Length; i++)
  87.             {
  88.                 int randomNumber = rng.Next(buckets[i].GetCapacity());
  89.                 buckets[i].Fill((double)randomNumber);
  90.                 ammounts[i] = randomNumber;
  91.             }
  92.            
  93.             int j = 1;
  94.  
  95.             while (j < ammounts.Length)
  96.             {
  97.                 if (ammounts[j] < ammounts[j - 1])
  98.                 {
  99.                     int holder = ammounts[j - 1];
  100.                     ammounts[j - 1] = ammounts[j];
  101.                     ammounts[j] = holder;
  102.                     if (j != 1)
  103.                         j--;
  104.                 }
  105.                 else
  106.                 {
  107.                     j++;
  108.                 }
  109.             }
  110.  
  111.             for (int i = 0; i < ammounts.Length; i++)
  112.                 Console.WriteLine(ammounts[i]);
  113.         }
  114.     }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement