玄关求调

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

liumoumou_haha @ 2024-12-05 21:20:02

#include<bits/stdc++.h>
using namespace std;
void op(int n,int m)
{
    if(n == 0) return ;
    else
    {
        op(n/m,m);
        if((n%m) >= 10)
        {
            cout << (n%m)-10+'A';
        }
        else
        {
            cout << (n%m); 
        }
    }
}
int main()
{
    int n,m;
    cin >> n >> m;
    op(n,m);    
    return 0;
}

by duantong @ 2024-12-05 21:24:09

#include<bits/stdc++.h>
using namespace std;
void op(int n,int m)
{
    if(n == 0) return;
    else
    {
        op(n/m,m);
        if((n%m) >= 10)
        {
            cout << char((n%m)-10+'A');
        }
        else
        {
            cout << (n%m); 
        }
    }
}
int main()
{
    int n,m;
    cin >> n >> m;
    op(n,m);    
    return 0;
}

by duantong @ 2024-12-05 21:24:23

@liumoumou_haha


by duantong @ 2024-12-05 21:24:44

第十一行


by liumoumou_haha @ 2024-12-05 21:34:41

感谢大佬!!!!!!


|