Fix binstr_to_int loop bug. Add lf prefix

This commit is contained in:
2021-12-21 06:48:29 -08:00
parent 6737c3a781
commit acf0164f4f
14 changed files with 33 additions and 20 deletions

View File

@ -1,28 +0,0 @@
#include <string.h>
#include "math.h"
int max_int(int a, int b) {
if (a > b) {
return a;
}
return b;
}
int min_int(int a, int b) {
if (a < b) {
return a;
}
return b;
}
int binstr_to_int(const char *s) {
int n = 0, m = 1;
for (size_t i = strlen(s) - 1; i >= 0; --i) {
if (s[i] == '1') {
n += m;
}
m *= 2;
}
return n;
}