using System;
using System.Collections.Generic;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
int x = int.Parse(Console.ReadLine());
List<int> list = new List<int>();
Console.Write("1");
while ( x / 2 >=1) {
if (x % 2 == 1)
{
list.Add(1);
}
else {
list.Add(0);
}
x = x / 2;
}
for (int i = list.Count-1; i >=0; i--) // Loop with for.
{
Console.Write(list[i]);
}
Console.ReadKey();
}
}
}
using System.Collections.Generic;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
int x = int.Parse(Console.ReadLine());
List<int> list = new List<int>();
Console.Write("1");
while ( x / 2 >=1) {
if (x % 2 == 1)
{
list.Add(1);
}
else {
list.Add(0);
}
x = x / 2;
}
for (int i = list.Count-1; i >=0; i--) // Loop with for.
{
Console.Write(list[i]);
}
Console.ReadKey();
}
}
}
No comments:
Post a Comment