Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random rnd = new Random();
- int num = rnd.Next(0, 1);
- int[] arithmos = new int[8];
- int pollap = 0;
- int synolo = 0;
- int iterator = 0;
- for (int i = 0; i < arithmos.Length; i++)
- {
- arithmos[i] = rnd.Next(0, 2);
- Console.Write(arithmos[i]);
- }
- for (int i=arithmos.Length-1; i>=0; i--)
- {
- switch (iterator)
- {
- case 0:
- pollap = 1;
- break;
- default: pollap = 2 * pollap;
- break;
- }
- if (arithmos[i] == 1)
- {
- synolo += pollap;
- iterator++;
- }
- }
- Console.WriteLine("\n" + synolo);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment