杭電 2051 Bitset

http://acm.hdu.edu.cn/showproblem.php?pid=2051

#include<stdio.h>
int main(){
	int n,a[30],i,j;
	while(scanf("%d",&n) == 1){
		i = 0;
		while(n){
			a[i++] = n%2;
			n = n/2;
		}
		for(j = i-1;j >= 0;j--){
			printf("%d",a[j]);
		}
		printf("\n");			
	}
	return 0;
}


發佈了38 篇原創文章 · 獲贊 12 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章