-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdigit.cpp
More file actions
72 lines (42 loc) · 1.21 KB
/
Copy pathdigit.cpp
File metadata and controls
72 lines (42 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <stdio.h>
#include <stdlib.h>
int main (){
int a[23]={0};
unsigned int b;
while (scanf("%u", &b)!=EOF){
int k=32;
unsigned int digit = 1<<(sizeof(b)*8-1);
// printf("%u", digit);
//printf ("and %d\n", b&digit);
while ((b&digit)==0)
{k--;
digit>>=1;
//printf("%d\n", b&digit);
}
//printf("here %d\n",k);
//const int t = k;
char c[k];
int i=0;
unsigned int f=b;
while (f!=0)
{
c[i++]=f&1;
f/=2;
//printf("la\n");
}
printf("siz =%d\n", sizeof(c));
for (i=sizeof(c)/sizeof(c[0]); i>0; i--)
printf("%d", c[i-1]);
printf("\n");
unsigned int p;
i=0;
while (b!=0)
{
if (b&1) i++;
b>>=1;
}
printf("%d\n",i);
}
system("pause");
return 0;
}