十进制转换成任意进制(栈的应用)
#include <iostream> #include <stack> using namespace std; int main() { stack<char> s; char a[37]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int x, n; scanf("%d%d", &x, &n); if (!x) printf("0"); else { while (x) { int ans = x % n; s.push(a[ans]); x /= n; } while (!s.empty()) { printf("%c", s.top()); s.pop(); } } return 0; }========================================Talk is cheap, show me the code=======================================
CSDN博客地址:https://blog.csdn.net/qq_34115899