0分!!!!!!!!!!

B3849 [GESP样题 三级] 进制转换

Sx0528 @ 2024-08-26 15:20:40

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    int n;
    int x;
    cin>>n>>x;
    int s,y;
    char d;
    while(s!=0)
    {
        s=n/x;
        y=n%x;
        if(y>10) d=y+55;
        else d=y+48;
        a+=d;
        n=s;
    }
    for(int i=a.size()-1;i>=0;i--)
    {
        cout<<a[i];
    }
    cout<<endl;
    return 0;
}

by xdd2014 @ 2024-08-26 15:26:06


#include<bits/stdc++.h>
using namespace std;
int a,b;
void jinzha(int x){
    if(x==0){
        return ;
    }
    else{
        jinzha(x/b);
        int t=x%b;
        if(t<10){
            cout<<t;
        }
        else{
            cout<<char(t+55);
        }
    }
}
int main(){
    cin>>a>>b;
    jinzha(a);
    return 0;
}

by xdd2014 @ 2024-08-26 15:26:26

@Sx0528


by Sx0528 @ 2024-08-26 15:28:44

已关,求回关


by xdd2014 @ 2024-08-26 15:30:06

@Sx0528,已回关


|