c++ 语言中有没有操作符可以将一个数的二进制代码输出来?

来源:百度知道 编辑:UC知道 时间:2024/06/24 16:07:01
我是说,有没有一个系统内置的操作符
比如
cout<<oct<<……
后面输出的就是八进制的数字
有没有一个操作符,可以使后面输出二进制的数字?

代码如下:
#include<iostream>
#include<vector>
using namespace std;
int main(){
cout<<"please input a decimal notation:";
int m;
cin>>m;
vector<int> a(2);
int i=0;
for(int n;n!=0;)
{int r;
n=m/2;
r=m%2;
m=n;
a[i]=r;
++i; }
cout<<"the result of transport is: ";
for(int j=i-1;j>=0;--j)
cout<< a[j];
}