26 lines
403 B
C++
26 lines
403 B
C++
//test1.cpp
|
|
#include"Stack.h"
|
|
#include<iostream>
|
|
using namespace std;
|
|
|
|
string getBinary(int i) {
|
|
stack s;
|
|
initStack(s);
|
|
while (i != 0) {
|
|
push(s, i % 2);
|
|
i /= 2;
|
|
}
|
|
string str = "";
|
|
while (!isEmpty(s)) {
|
|
str += pop(s) + '0';
|
|
}
|
|
return str;
|
|
}
|
|
|
|
int main() {
|
|
int decimal;
|
|
cin >> decimal;
|
|
cout << getBinary(decimal) << endl;;
|
|
return 0;
|
|
}
|