标签:des blog io os sp 数据 div on log
7 2 23 12 -4 3
111 1B -11
#include <iostream> #include <string> #include <stdio.h> #include <string.h> #include <map> #include <stack> #include <algorithm> #include <ctype.h> using namespace std; int main() { int n, r, dd, ff; int i, j; int flag; while(scanf("%d %d", &n, &r)!=EOF) { flag=0; stack<int>q; if(n==0) { printf("0\n"); continue; } if(n<0) { flag=1; n=-n; } while(n!=0) { dd = n%r; q.push(dd); n/=r; } if(flag==1) { printf("-"); } while(!q.empty()) { ff=q.top(); q.pop(); if(ff>=10) { printf("%c", ff+55); } else { printf("%d", ff); } } printf("\n"); } return 0; }
标签:des blog io os sp 数据 div on log
原文地址:http://www.cnblogs.com/yspworld/p/4079656.html