主页 > 游戏开发  > 

数据结构——模拟栈例题B3619

数据结构——模拟栈例题B3619

B3619 10 进制转 x 进制 - 洛谷

#include <bits/stdc++.h> using namespace std; #define fs first #define sc second #define endl '\n' #define all(x) x.begin(), x.end() typedef long long ll; typedef pair<int, int> PII; char a[40]; void solve(){ int n,x; cin>>n>>x; int h=0; while(n>=x) { int t=n%x; if(t>=10) a[h++]='A'+t-10; else a[h++]=t+'0'; n/=x; } if(n>=10) a[h++]='A'+n-10; else a[h++]=n+'0'; for(int i=h-1;i>=0;i--)cout<<a[i]; } int main(){ cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); int t; t=1; while (t--) { solve(); } return 0; }

标签:

数据结构——模拟栈例题B3619由讯客互联游戏开发栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“数据结构——模拟栈例题B3619