#include<iostream>
#include<cmath>
using namespace std;
const int N_1=19;
const int N_2=2;
void main()
{
int x = log(N_1)/log(2);
int y = log(N_2)/log(2);
int temp = x;
int u = 0;
int flag = false;
if((N_1>>(x-y))==N_2)
{
cout << "ok" << endl;
for(int w =N_2;w<=N_1;w++)
{
if(!((w)& (w- 1)) & !!(w)&&w!=3)
{
if(w!=2)
u++;
}
if(w>>u==N_2) cout <<w<< endl;
}
}
}
#include<cmath>
using namespace std;
const int N_1=19;
const int N_2=2;
void main()
{
int x = log(N_1)/log(2);
int y = log(N_2)/log(2);
int temp = x;
int u = 0;
int flag = false;
if((N_1>>(x-y))==N_2)
{
cout << "ok" << endl;
for(int w =N_2;w<=N_1;w++)
{
if(!((w)& (w- 1)) & !!(w)&&w!=3)
{
if(w!=2)
u++;
}
if(w>>u==N_2) cout <<w<< endl;
}
}
}
本示例通过位操作和条件判断实现特定数值范围内的筛选。程序首先判断两个预设整数之间的特殊关系,然后在指定范围内找出符合特定位模式的整数。
742

被折叠的 条评论
为什么被折叠?



