18 lines
277 B
C++
18 lines
277 B
C++
#include <iostream>
|
|
#include <cmath>
|
|
|
|
#include "converts.h"
|
|
|
|
int str2int(string s) {
|
|
int r = 0;
|
|
int i = 0;
|
|
for(auto s_it = s.rbegin(); s_it != s.rend(); s_it++) {
|
|
if (*s_it == '1') {
|
|
r += pow(2, i);
|
|
}
|
|
|
|
i++;
|
|
}
|
|
return r;
|
|
}
|