程序是用来给人阅读的,顺便给计算机运行而已……
---aw3
// dec2bin.cpp : aw3 2013-10.
//#include "stdafx.h"
//#include<iostream>
#include<stack> //使用栈必加
int main(int argc, char* argv[])
{
printf("Hello World!\n");
std::stack<unsigned short> c;
int a=253; //(10进制)数,要转化为二进制的…
unsigned short b=0;
printf("b=");
for (;0!=a;) {
b=a%2; //b为取模
a=a/2; //其实为(短除并)取模的计次数
// printf("%d",b);
c.push(b); //入(c的)栈
}
printf("正序为:");
while(!c.empty() ) {
printf("%d",c.top() );
c.pop();
}
return 0;
}