#include<iostream>
using namespace std;
int main()
{
long long int n;
int a[50], i, c, d, j;
while(cin >> n)
{
if(n == 0)
break;
i = 0, c = 0, d = 0;
while(n>0)
{
c = n%2;
n = n/2;
if(c == 1)
d++;
a[i] = c;
i++;
}
cout << "The parity of ";
for(j=i-1;j>=0;j--)
{
cout << a[j];
}
cout << " is " << d << " (mod 2)." << endl;
}
return 0;
}
using namespace std;
int main()
{
long long int n;
int a[50], i, c, d, j;
while(cin >> n)
{
if(n == 0)
break;
i = 0, c = 0, d = 0;
while(n>0)
{
c = n%2;
n = n/2;
if(c == 1)
d++;
a[i] = c;
i++;
}
cout << "The parity of ";
for(j=i-1;j>=0;j--)
{
cout << a[j];
}
cout << " is " << d << " (mod 2)." << endl;
}
return 0;
}
Comments
Post a Comment