DonJabone

SheetsSMasiv

Jun 10th, 2013
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using System;
  2.  
  3. class SheetsSMasivi
  4. {
  5.     static void Main()
  6.     {
  7.         int sum = int.Parse(Console.ReadLine());
  8.         int[] MyArray = { 1024 , 512 , 256 , 128 , 64 , 32 , 16 , 8 , 4 , 2 , 1};
  9.         for (int i = 0; i < MyArray.Length; i++)
  10.         {
  11.             if (sum - MyArray[i] >= 0 && sum !=0)
  12.             {
  13.                 sum = sum - MyArray[i];
  14.             }
  15.             else
  16.             {
  17.                 Console.WriteLine("A" + i);
  18.             }
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment