二进制转十进制

[复制链接]
查看11 | 回复2 | 2006-1-23 16:46:42 | 显示全部楼层 |阅读模式
#include"stdio.h" #define base 2 /*这里你可以转换任何进制的数,这里是2进制*/ int main() { int n; int str[1000]; int i,j; while(scanf("%d",&n)!=EOF){ i=0; while(n){ str=n%base; i++; n=n/base; } if(i==0) printf("0"); for(j=i-1;j>=0;j--) printf("%d",str[j]); printf("\n"); } }
回复

使用道具 举报

千问 | 2006-1-23 16:46:42 | 显示全部楼层

回复

使用道具 举报

千问 | 2006-1-23 16:46:42 | 显示全部楼层
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行