21.MFC进制转换工具
相关代码:链接:https://pan.baidu.com/s/1pKVVUZL 密码:e3vf
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include <math.h> //从2进制转到10进制
int from_2to10(char res[])
{
printf("%s", res);
int result = ;
int len = strlen(res);
//从最高位开始依次计算
for (int i = ; i < len; i++)
{
result += (res[i] - '') * pow(2.0, len - i - );
} return result;
}
//从8进制转到10进制
int from_8to10(char res[])
{
int result = ;
int len = strlen(res);
//从最高位开始依次计算
for (int i = ; i < len; i++)
{
result += (res[i] - '') * pow(8.0, len - i - );
} return result;
}
//从16进制转到10进制
int from_16to10(char res[])
{
int result = ;
int len = strlen(res);
//从最高位开始依次计算
for (int i = ; i < len; i++)
{
if (res[i] - '' < )
{
result += (res[i] - '') * pow(16.0, len - i - );
}
else
{
result += ( + res[i] - 'A') * pow(16.0, len - i - );
}
} return result;
}
//10进制转到2进制
void to2(int num, char res[], int i)
{
if (num == )
{
return;
}
else
{
res[i] = '' + num % ;
to2(num / , res, i + );
}
}
//10进制转到8进制
void to8(int num, char res[], int i)
{
if (num == )
{
return;
}
else
{
res[i] = '' + num % ;
to8(num / , res, i + );
}
}
//10进制转到16进制
void to16(int num, char res[], int i)
{
if (num == )
{
return;
}
else
{
if (num % >= && num % <= )
{
res[i] = '' + num % ;
}
else
{
res[i] = 'A' + num % - ;
} to16(num / , res, i + );
}
}
21.MFC进制转换工具的更多相关文章
- 在线任意进制转换工具 - aTool在线工具
http://www.atool.org/hexconvert.php ss = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQ ...
- mfc进制转换
; CString str; m_edit1.GetWindowTextW(str); swscanf_s(str, _T("%d"), &num); _TCHAR str ...
- 最全面的Java字节byte操作,处理Java基本数据的转换及进制转换操作工具,流媒体及java底层开发项目常用工具类
前言:用于处理Java基本数据的转换及进制转换操作工具 一.实现功能 1.int与byte互转 2.int与byte[]互转 3.short与byte互转 4.short与byte[]互转 5.16位 ...
- JAVA之旅(一)——基本常识,JAVA概念,开发工具,关键字/标识符,变量/常量,进制/进制转换,运算符,三元运算
JAVA之旅(一)--基本常识,JAVA概念,开发工具,关键字/标识符,变量/常量,进制/进制转换,运算符,三元运算 Android老鸟重新学一遍JAVA是什么感觉?枯燥啊,乏味啊,而且归纳写博客,都 ...
- java se系列(二) 关键字、注释、常量、进制转换、变量、数据类型转换、运算符
1 关键字 1.1 关键字的概述 Java的关键字对java的编译器有特殊的意义,他们用来表示一种数据类型,或者表示程序的结构等,关键字不能用作变量名.方法名.类名.包名. 1.2 常见的关键字 备注 ...
- JS中的进制转换以及作用
js的进制转换, 分为2进制,8进制,10进制,16进制之间的相互转换, 我们直接利用 对象.toString()即可实现: //10进制转为16进制 ().toString() // =>&q ...
- Java基础复习之一篇:关健字,标识符,注释,常量,进制转换,变量,数据类型,数据类型转换
1.关健字 1.1.被Java语言赋予特定意义的单词(如:class,interface,public ,static) 1.2.全部是小写 1.3.注意事项(goto和const作为关健字保留起来) ...
- jstack:将Process Explorer中看到的进程ID做16进制转换,到ThreadDump中加上0x 前缀即能找到对应线程(转)
原文链接:http://www.iteye.com/topic/1133941 症状: 使用Eclipse win 64位版本,indigo及kepler都重现了,使用tomcat 6.0.39,jd ...
- python 进制 转换
测试用的python源码 ''''' Created on 2014年8月21日 @author: lenovo ''' import binascii import struct def examp ...
随机推荐
- java zyUpload 实现多文件上传
1.html部分 <form enctype="multipart/form-data"> <label>请选择文件</label> <i ...
- 【BZOJ 1208】[HNOI2004]宠物收养所
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用set搞. (因为规定了不会有相同特点值的东西. 所以可以不用multiset. 那么每次用lower_bound找离它最近的配对 ...
- LaTeX 设置字体颜色
本系列文章由 @YhL_Leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50240179 需要包含宏包: \use ...
- 【转】C# 正则表达式大全
[转]C# 正则表达式大全 前言 在网上看到一个不错的简易版正则匹配和替换的工具,现在补充进来,感觉还不错,效果如下(输入验证中文汉字的正则表达式) 在线下载 密码:5tpt 注:好像也是一位园友 ...
- 三期_day02_数据库表设计和开发准备工作
数据库脚本 drop table crm_user_info; drop table crm_work_customer_relation; drop table crm_business; drop ...
- Dictionaries and lists
Lists can appear as values in a dictionary. For example, if you were given a dictionary that maps fr ...
- hdu1978 How many ways
How many ways Problem Description 这是一个简单的生存游戏,你控制一个机器人从一个棋盘的起始点(1,1)走到棋盘的终点(n,m).游戏的规则描述如下: 机器人一开始在棋 ...
- POJ 3661 DP
题意: 思路: i表示到了i,j表示疲劳度为j f[i][j]表示能跑的最大距离 f[i][j]=f[i-1][j-1]+a[i] if(i-j>=0)f[i][0]=max(f[i][0],f ...
- mysql读写分离的解决方案
来源于网上整理 http://yanwt.iteye.com/blog/1460780 现有三种解决方式实现mysql读写分离 1 程序修改mysql操作类 优点:直接和数据库通信,简单快捷的读写分离 ...
- webService接口发布失败问题
今天在原有工程上新增加了个webService接口的服务类,但是总提示 axis2 出错 File "/axis2-web/listSingleService.jsp" not f ...