Data structure experiment stack 1: hexadecimal conversion Time Limit: 1000 MS Memory limit: 65536 K Title Description enter a decimal integer, convert it to the corresponding R (2 <= R <= 9) hexadecimal number and output it. Enter the number of decimal places to be converted in the first line and R in the second line. Output The number of R in hexadecimal format. Sample input 12798 sample output 2377 [html] # include <cstdio> # include <cstdlib> # include <cstring> # include <stack> using namespace std; int main () {stack <int> S; int a, r; while (scanf ("% d", & a, & r )! = EOF) {while (a> 0) {S. push (a % r); a = a/r;} while (! S. empty () {int t; t = S. top (); printf ("% d", t); S. pop () ;}printf ("\ n") ;}return 0 ;} # include <cstdio> # include <cstdlib> # include <cstring> # include <stack> using namespace std; int main () {stack <int> S; int a, r; while (scanf ("% d", & a, & r )! = EOF) {while (a> 0) {S. push (a % r); a = a/r;} while (! S. empty () {int t; t = S. top (); printf ("% d", t); S. pop () ;}printf ("\ n") ;}return 0 ;}function implementation # include <cstdio >#include <cstdlib> using namespace std; int main () {char s [10001]; int a, r; while (scanf ("% d", & a, & r )! = EOF) {itoa (a, s, r); puts (s) ;}return 0 ;}