-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLib.cpp
More file actions
39 lines (35 loc) · 666 Bytes
/
Lib.cpp
File metadata and controls
39 lines (35 loc) · 666 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
#include "Lib.h"
ui ScanBoolVector(char v[], int n){
ui x = 0;
for(int i = 0; i < n; ++i){
x <<= 1;
if(v[i] == '1'){
x++;
}
}
return x;
}
void PrintBoolVector(ui x, int n){
ui mask = 1;
mask <<= n-1;
for(int i = 0; i < n; i++){
printf("%d", (x&mask) ? 1 : 0);
mask >>= 1;
}
}
void ScanBoolMatrix(ui *BoolMatrix, int m, int n){
char *s = new char[n];
for(int i = 0; i < m; ++i){
scanf("%c", s);
for(int j = 0; j < n; ++j){
scanf("%c", s+j);
}
BoolMatrix[i] = ScanBoolVector(s, n);
}
}
void PrintBoolMatrix(ui *BoolMatrix, int m, int n){
for(int i = 0; i < m; ++i){
PrintBoolVector(BoolMatrix[i], n);
printf("\n");
}
}