1 #include<iostream>
 2 #include<vector>
 3 using namespace std;
 4 int fun(int i)
 5 {
 6     if(i==1){
 7     return 0;
 8     }
 9       if (i&&!(i&(i-1)))

10             return 1;
11 
12       else
13             return 0;
14 }
15 
16 int main()
17 {
18       vector<int> vel;
19       int x;
20       bool A;
21       while(cin>>x)
22       {
23             A=fun(x);
24             vel.push_back(A);
25       }
26       vector<int>::iterator it;
27       for(it=vel.begin();it!=vel.end();it++)
28       {
29             if(*it==1)
30             {
31                 cout<<"true"<<endl;
32             }
33             else{
34             cout<<"false"<<endl;
35             }
36       }
37       return 0;
38 }


输入若干行,判断是否为2的次幂。。。。。

相关文章:

  • 2021-06-18
  • 2022-12-23
  • 2022-02-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2021-06-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2021-12-18
  • 2021-09-13
  • 2021-11-18
相关资源
相似解决方案