Files
data-structures-and-algorithms/homework3/test1.cpp
T
2024-10-23 21:27:48 +08:00

25 lines
391 B
C++

#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;
}