#include <conio.h>
#define max 20
#define max_2 4*max
#define yes '1'
#define no '0'
using namespace std;
char *bits_F;
int *value_F;
bool is_First(int value)
{
int i,sum;
sum=0;
for(i=1;i<value+1;i++)
if(value%i==0)
++sum;
if(sum==2)
return true;
else
return false;
}
void test_Bits(char bit,char *tab_Bytes)
{
int value,i;
for(i=max-1;i>=0;i--)
{
value=(tab_Bytes[i]&bit);
if(value!=0)
cout<<yes;
else
cout<<no;
}
}
int main()
{
int i,j;
int negation;
bits_F=new char[max];
value_F=new int[max_2];
i=0;
j=2;
do
{
if(is_First(j))
{
bits_F[i]=j;
++i;
}
++j;
}while(i<max);
i=0;
j=2;
do
{
if(is_First(j))
{
value_F[i]=j;
++i;
}
++j;
}while(i<max_2);
for(i=0;i<max_2;i++)
{
negation=~i;
cout<<i+1<<"\t";
cout<<value_F[i]<<"\t";
test_Bits(i+1,bits_F);cout<<"\t";
test_Bits(negation+1,bits_F);
cout<<endl;
}
delete bits_F;
delete value_F;
getch();
return 0;
}
Brak komentarzy:
Prześlij komentarz