#include <stdio.h>
int main()
{
printf("Enter an integer: ");
int integer;
scanf("%d", &integer);
unsigned count = 0;
do
{
if (integer % 2)
++count;
} while (integer /= 2);
printf("Total of 1 is %u.\n", count);
return 0;
}
#include <stdio.h>
int main()
{
printf("Enter an integer: ");
int integer;
scanf("%d", &integer);
unsigned count = 0;
do
{
if (integer % 2)
++count;
} while (integer /= 2);
printf("Total of 1 is %u.\n", count);
return 0;
}
转载于:https://www.cnblogs.com/buyishi/p/8481311.html