80求助!!!

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

lce11451410086 @ 2024-11-14 20:59:54


#include<bits/stdc++.h>
using namespace std;
void s(int n,int m){
    if(n==0){
        return ;
    }
    else{
        s(n/m,m);
        if((n%m)>=10){
            printf("%c",(n%m%10)+'A');
        }else{
            printf("%d",n%m);
        }
    }
}
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    s(n,m);
    return 0;
}
```回复给关

by xywuyu @ 2024-11-14 21:11:11

#include<bits/stdc++.h>
using namespace std;
void s(int n,int m){
    if(n==0){
        return ;
    }
    else{
        s(n/m,m);
        if((n%m)>=10){
            printf("%c",(n%m-10)+'A');
        }else{
            printf("%d",n%m);
        }
    }
}
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    s(n,m);
    return 0;
}

by xywuyu @ 2024-11-14 21:11:22

@lce11451410086


by lce11451410086 @ 2024-11-15 21:22:46

@xywuyu 谢谢,已关


|