过客
路过!
posts - 133, comments - 31, trackbacks - 2, articles - 3
博客园
::
首页
::
新随笔
::
联系
::
订阅
::
管理
日历
公告
10进制转化为2进制
Posted on
2008-12-17 12:35
过客路过
阅读(216) 评论(
1
)
编辑
收藏
Code
using System;
using System.Collections;
class Ten
{
static void Main()
{
Console.WriteLine("Input the number!");
int ten=Int32.Parse(Console.ReadLine().Trim());
ArrayList al=new ArrayList();
while(ten>0)
{
if(ten%2==0)
{
al.Add(0);
ten=ten/2;
}else
{
al.Add(1);
ten=ten/2;
}
};
for(int i=al.Count-1;i
<
al
.Count;i--)
{
if(i<0)break;
Console.Write(al[i]);
}
}
}
刷新评论
刷新页面
返回顶部
程序员问答社区,解决您的IT难题
博客园首页
博问
新闻
闪存
程序员招聘
知识库
Powered by:
博客园
Copyright © 过客路过