Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stack> //biblioteka_stosa
- using namespace std;
- string dec2bin(int dec)
- {
- stack<int> s; //stos
- string bin = "";
- while(dec)
- {
- s.push(dec%2); //wrzucenie_na_stos
- dec/=2;
- }
- while(!s.empty()) //wykrzyknik_to_zaprzeczenie
- {
- bin += (char)(s.top()+'0');
- s.pop();
- }
- return bin;
- }
- int main()
- {
- int dec;
- cin >> dec;
- cout << dec2bin(dec) << endl; //(dec)_bo trzeba wrzucić funkcje tam jeszcze
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement