-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11_27.c
80 lines (77 loc) · 1.18 KB
/
11_27.c
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
73
74
75
76
77
78
79
80
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
//int main()
//
//{/*不创建临时变量2交换两个元素
// int a = 0;
// int b = 0;
// scanf("%d %d", &a, &b);
// printf("a=%d b=%d\n", a, b);
// a = a ^ b;
// b = a ^ b;
// a = a ^ b;
// printf("a=%d b=%d", a, b);*/
// return 0;
//}
//统计32位二进制数中1的个数
//int theNumberof1(int b)
//{
// int cnt = 0;
// for (int i = 0; i < 32; i++)
// {
// cnt += (b >> i) & 1;
// }
// return cnt;
//}
//int main()
//{
// int b = 0;
// scanf("%d", &b);
// int ret = theNumberof1(b);
// printf("%d", ret);
// return 0;
//}
//打印二进制中奇数位和偶数位
//void Print(int n)
//{
// //打印偶数位
// for (int i = 30; i >=0 ; i -= 2)
// {
// printf("%d ", (n >> i) & 1);
// }
// printf("\n");
// for (int i = 31; i >= 1; i -= 2)
// {
// printf("%d ", (n >> i) & 1);
// }
//}
//int main()
//{
// int n = 0;
// scanf("%d", &n);
// Print(n);
// return 0;
//}
//
//
//
//int the_diff_num(int a, int b)
//{
// int c = a ^ b;
// int cnt = 0;
// while (c)
// {
// cnt++;
// c = c & (c - 1);//统计c中有多少个1
// }
// return cnt;
//}
//int main()
//{
// int a = 0;
// int b = 0;
// scanf("%d %d", &a, &b);
// int ret = the_diff_num(a, b);
// printf("%d", ret);
// return 0;
//}