Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Translating binary to decimal numbers
#include<iostream> using namespace std; class number { private: int byte[8]; int sum; public: number() : sum(0) { } void binar() { for(int i=0;i<8;i++) { cin>>byte[i]; }} int btod() { if(byte[0]==1) sum+=128; if(byte[1]==1) sum+=64; if(byte[2]==1) sum+=32; if(byte[3]==1) sum+=16; if(byte[4]==1) sum+=8; if(byte[5]==1) sum+=4; if(byte[6]==1) sum+=2; if(byte[7]==1) sum+=1; return sum; } void decimal() { cout<<sum<<endl; } }; int main() { number s; s.binar(); s.btod(); s.decimal(); }
run
|
edit
|
history
|
help
0
replace_copy-30-Seconds-of-C++
ADP_campus
Test 5(2020)
error
Avoiding visited networked paths
Średnia bez zera
СПКИ АП КЭП 3
Christopher-Stellar
0/1Knapsack
Pac update