标签:c++ while name int its 思路 else char return
#include<bits/stdc++.h>
using namespace std;
int main(){
char s[105];
int x,y;
while(scanf("%d %d",&x,&y)!=EOF){
scanf("%s",s);
int ans=0;
int len=strlen(s);
for(int i=0;i<len;i++){
ans=ans*x;
if(s[i]>‘0‘&&s[i]<=‘9‘)ans+=(s[i]-‘0‘);
else ans+=(s[i]-‘A‘)+10;
}
char out[105];
int cnt=0;
while(ans>0){
int w=(ans%y);
if(w<10)out[cnt++]=w+‘0‘;
else out[cnt++]=(w-10)+‘a‘;
ans/=y;
}
for(int i=cnt-1;i>=0;i--){
printf("%c",out[i]);
}
}
printf("\n");
return 0;
}
思路:x--->10---->y
标签:c++ while name int its 思路 else char return
原文地址:https://www.cnblogs.com/suehoo/p/14613645.html