Created the base_2_to_10_static.cpp
This commit is contained in:
parent
3ccc794772
commit
958d24ec07
21
base_2_to_10_static.cpp
Normal file
21
base_2_to_10_static.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int bits[3] = {1, 1, 1};
|
||||
|
||||
int length = sizeof(bits) / sizeof(bits[0]);
|
||||
|
||||
int num = 0;
|
||||
|
||||
int modifier = 1;
|
||||
for (int i = 0; i < length; i++) {
|
||||
num += modifier * bits[length - i - 1];
|
||||
modifier *= 2;
|
||||
}
|
||||
|
||||
cout << num;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user