学***佬,请问还有什么题吗,方便透露一下,练练手,感谢~ #include <iostream> using namespace std; int main() {     int n;     cin>>n;     int num = 0;     for(int i = 0;i <= n;i++)     {         for(int j = i;j > 0;j>>=1)         {             int temp1 = j & 1;             j>>=1;             cout<<j<<":"<<temp1<<endl;             int temp2 = j & 1;             j>>=1;             cout<<j<<":"<<temp2<<endl;             int temp3 = j & 1;             cout<<j<<":"<<temp3<<endl;             if(temp1 == 1 && temp2 == 1 && temp3 == 1)             {                 num++;             }         }     }     cout<<num;     return 0; }
点赞 评论

相关推荐

牛客网
牛客企业服务