回复 10楼 叶纤
大佬大佬
2020-03-10 13:15
2020-03-10 13:18

2020-03-10 13:27
程序代码:
#include<iostream>
using namespace std;
int main(){
int i=0,n,m,a[100];
cin>>n>>m;
while(n!=0){
a[i]=n%m;
n/=m;
i++;
}
for(int j=i-1;j>=0;j--){
if(a[j]>=10)
cout<<(char)(a[j]-10+'A');
else
cout<<a[j];
}
return 0;
}

2020-03-10 13:29
程序代码:
#include<iostream>
#include<string>
using namespace std;
int main(){
string s;
int m=16;
cin>>s;
string temp1=s;
int len=s.length();
int weight = 1, asw = 0;
for(int i=len-1;i>=0;i--){
if(s[i]<='9')
asw=asw+(s[i]-'0')*weight;
else
asw=asw+(s[i]-'A'+10)*weight;
weight*=m;
}
cout<<asw<<" ";
for(int i=0;i<len;i++){
cout<<s[i];
}
return 0;
}

2020-03-10 13:36

2020-03-10 13:37
2020-03-10 13:39
2020-03-10 13:42
2020-03-10 13:53

2020-03-10 14:15