Saleh127

Untitled

Apr 20th, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int a[1000000];
  4. int main()
  5. {
  6. long long b,c,d,e,f,i,j,k,l;
  7. while(1)
  8. {
  9. cin>>b;
  10. c=0;
  11. d=0;
  12. i=0;
  13. if(b==0) break;
  14. while(b!=0)
  15. {
  16. c=b%2;
  17. a[i]=c;
  18. i++;
  19. if(c==1)
  20. d++;
  21. b=b/2;
  22. }
  23. printf("The parity of ");
  24. for(j=i-1; j>=0; j--)
  25. {
  26. printf("%d",a[j]);
  27. }
  28. printf(" is %d (mod 2).\n",d);
  29.  
  30. }
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment