本文最后更新于 197 天前,其中的信息可能已经有所发展或是发生改变。
首先是10进制转换为k进制,用数组a[]表示
| #include<iostream> |
| #include<cstring> |
| #include<algorithm> |
| |
| using namespace std; |
| |
| int main(){ |
| |
| int x,k;cin>>x>>k; |
| int z[10010],cnt=0; |
| while(x){ |
| z[++cnt] = x % k, x /= k; |
| } |
| reverse(z+1,z+cnt+1); |
| |
| for(int i = 1;i<cnt+1;i++) cout<<z[i]; |
| |
| return 0; |
| } |
| #include<iostream> |
| #include<cstring> |
| #include<algorithm> |
| |
| using namespace std; |
| |
| int main(){ |
| int x,k;cin>>x>>k; |
| int a[10010],cnt=0; |
| while(x) a[++cnt] = x%10,x/=10; |
| reverse(a+1,a+cnt+1); |
| int z = 0; |
| for(int i = 1;i<=cnt;i++){ |
| z = z*k+a[i]; |
| } |
| cout<<z<<endl; |
| |
| return 0; |
| } |