-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuncs29.cpp
More file actions
40 lines (36 loc) · 874 Bytes
/
funcs29.cpp
File metadata and controls
40 lines (36 loc) · 874 Bytes
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
#include <iostream>
bool miror(unsigned long long& num) {
int length = 0;
unsigned long long num1 = num;
while (num1 != 0) {
num1 >>= 1;
length++;
}
<<<<<<< HEAD
=======
>>>>>>> 07f38bcb5a8691e0f9da8b0e3934363f1fd0a694
int p1{ 0 };
int p2{ length };
int bit1, bit2;
if (length % 2 == 0) {
while (p1 != p2) {
bit1 = (num >> p1) & 1;//ïîëó÷åíèå çíà÷åíèÿ áèòà
bit2 = (num >> p2) & 1;
if (bit1 != bit2) {
return -1;
}
p1++; p2--;
}
}
else {
while (p1 != length/2 and p2 != length / 2) {
bit1 = (num >> p1) & 1;//ïîëó÷åíèå çíà÷åíèÿ áèòà
bit2 = (num >> p2) & 1;
if (bit1 != bit2) {
return -1;
}
p1++; p2--;
}
}
return 0;
}