using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Threading; namespace ConsoleApp3 { class Program { static void Main(string[] args) { Console.Write("Irjon be egy szamot : "); int szam = int.Parse(Console.ReadLine()); int szamt = szam; int db = 0; do { szamt = szamt / 2; db++; } while (szamt != 1); db++; int[] tomb = new int[db]; int i = 0; do { if (szam >= 1) { if (szam % 2 == 0) { tomb[i] = 0; } else if (szam % 2 == 1) { tomb[i] = 1; } szam = szam / 2; i++; } } while (szam > 0.99); Console.Write("\n\nA szam: "); for (int l = tomb.Length - 1; l >= 0; l--) { Console.Write(tomb[l]); } //komplementer for (int l = tomb.Length - 1; l >= 0; l--) { if (tomb[l] == 1) { tomb[l] = 0; } else if (tomb[l] == 0) { tomb[l] = 1; } } Console.Write("\n\nkomplementer: "); for (int l = tomb.Length - 1; l >= 0; l--) { Console.Write(tomb[l]); } Console.ReadKey(); } } }