Advertisement
Anonim_999

bit

May 15th, 2021
1,156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Threading;
  4. namespace scumbler
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string[] bits = new string[] { "10101011", "10101100", "10101101", "10101110", "10101111","10110001","10110010",
  11.                 "10110011", "10110100", "10110101", "10110110", "10110111", "10111000", "10111001", "10111010", "10111011"};
  12.             for (int i = 0; i < bits.GetLength(0); i++)
  13.             {
  14.                 string bit = bits[i];
  15.                 int numberOne = 0;
  16.                 Console.Write($"{i} Байт - {bit} || ");
  17.  
  18.                 for (int j = 0; j < bit.Length - 1; j++)
  19.                 {
  20.                     if (bit[j] == '1')
  21.                     {
  22.                         numberOne++;
  23.                     }
  24.                 }
  25.  
  26.                 if (numberOne % 2 == 0)
  27.                 {
  28.                     Console.Write("1\n");
  29.                 }
  30.                 else
  31.                 {
  32.                     Console.Write("0\n");
  33.                 }
  34.  
  35.  
  36.             }
  37.            
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement