文章

70

粉丝

0

获赞

226

访问

7.0k

头像
IP地址 题解:手动转进制
P1023 贵州大学机试题
发布于2026年3月20日 14:48
阅读数 120

#include<stdio.h>
#include<malloc.h>
#include<iostream>
#include<math.h>
#include<stack>
#include<string>
#include<map>
#include<algorithm>

using namespace std;

int string_to_num(string nt){   //字符串转为十进制数值
    int num=0;
    for(int i=0; i<nt.length(); i++){
        num*=10;
        num+= (nt[i]-'0');
    }
    return num;
}

string num_to_0x(int num){        //十进制数转为十六进制字符串
    string c="";
    while(num>0){
        char w = (num%16);
        if(w<10) w = w + '0';  //为0~9
        else w = w-10 + 'A';  //为十六进制字母
        c+=w;  //逆序接入
   &nbs...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发