// Convert the data in decimal format to binary type, and use the advanced post-export principle of stack # include <cstdio> # include <stack> using namespace std; int main () {int n; stack <int> s; while (scanf ("% d", & n )! = EOF) {while (! S. empty () s. pop (); // clear the top elements of the stack one by one // convert the elements to binary in decimal format, and use the advanced post-release principle of the stack # include <cstdio> # include <stack> using namespace std; int main () {int n; stack <int> s; while (scanf ("% d", & n )! = EOF) {while (! S. empty () s. pop (); // clear the top elements of the stack one by one
// ClearStack (& s); why cannot I directly clear it here ?? Usage error ???
While (n> 0) {s. push (n % 2); n/= 2;} while (! S. empty () {printf ("% d", s. top (); // outputs the top elements of the stack one by one, followed by s. pop (); // clear the top elements of the stack one by one} puts (""); // use getchat (); absorption, puts output returns 0 ;} while (n> 0) {s. push (n % 2); n/= 2;} while (! S. empty () {printf ("% d", s. top (); // outputs the top elements of the stack one by one, followed by s. pop (); // clear the top elements of the stack one by one} puts (""); // use getchat (); absorption, puts output returns 0 ;}