运算出各种整形数据的范围和所占用的内存字节数完整代码
作者:2011/4/18 13:59:17

分享EXE文件(可运算出各种整形数据的范围和所占用的内存字节数)代码,供C++好友产考学习,以上已经过测试,完全不含有任何错误,如有疑问,请咨询:***  : 837035641

#include "stdafx.h"
#include <limits.h>
#include <iostream>
int main(int argc, char* argv[])
{
 short nShortMin = SHRT_MIN;                          //***小有符号短整型
 short nShortMax = SHRT_MAX;                          //***大无符号短整型
 unsigned short nUshortMax = USHRT_MAX;               //***大无符号短整型
 int nIntMin = INT_MIN;                               //***小有符号整形
 int nIntMax = INT_MAX;                               //***大有符号整形
 unsigned nUIntMax = UINT_MAX;                        //***大无符号整形
 long nLongMin = LONG_MAX;                            //***小有符号长整型
 long nLongMax = LONG_MIN;                            //***大有符号长整型
 unsigned long nULongMax = ULONG_MAX;                 //***大无符号长整型
 printf("有符号短整型占用内存为%d,***大值和***小值分别为%d和%d;\n",sizeof(short),nShortMin,nShortMax);
                                                      //输出有符号短整型
 printf("无符号短整型占用内存为%d,***大值为%d;\n",sizeof(unsigned short),nUshortMax);
                                                         //输出无符号短整型
 printf("有符号整形占用内存为%d,  ***小值与***大值分别为%d和%d;\n",sizeof(int),nIntMin,nIntMax);
                                                      //输出有符号整形
 printf("无符号整形占用内存为%d,  ***大值为%u; \n",sizeof(unsigned int),nUIntMax);
                                                      //输出无符号整形
 printf("有符号长整型占用内存为%d,***大值与***小值分别为%ld和%ld;\n",sizeof(long),nLongMin,nLongMax);
                                                      //输出有符号长整型
 printf("无符号长整型占用内存为%d,***大值为%u; \n",sizeof(unsigned long),nULongMax);
    return 0;
}
 

商户名称:上海睦腾智能科技有限公司

版权所有©2024 产品网