将int型转换成二进制

来源:互联网 发布:淘宝联盟导出excel后 编辑:程序博客网 时间:2024/05/29 19:06
//使用容器转换二进制 int BinaryVector(int n){    int temp= n;    vector<int>ivec;    while (temp != 0)    {        ivec.push_back(temp % 2);        temp = temp>>1;    }    for (auto i:ivec)        cout<<i<<" ";    cout<<endl;    return 0;}
原创粉丝点击