转载:
看别人代码突然发现还有climits(limits.h)这么个头文件,以后初始化最大值最小值什么的就方便多
- 符号常量 表示
- CHAR_BIT char 的位数
- CHAR_MAX char 的最大值
- CHAR_MIN char 的最小值
- SCHAR_MAX signed char 的最大值
- SCHAR_MIN signed char 的最小值
- UCHAR_MAX unsigned char 的最大值
- SHRT_MAX short 的最大值
- SHRT_MIN short 的最小值
- USHRT_MAX unsigned short 的最大值
- INT_MAX int 的最大值
- INT_MIN int 的最小值
- UNIT_MAX unsigned int 的最大值
- LONG_MAX long 的最大值
- LONG_MIN long 的最小值
- LONG_MAX unsigned long 的最大值
-
- 表 3.1 climits中的符号常量
-
-
- #include <iostream>
- #include <climits>
- using namespace std;
- int main()
- {
- cout << "Size:" << endl;
- cout << "int is " << sizeof (int) << "bytes." << endl;
- cout << "short is " << sizeof (short) << "bytes." << endl;
- cout << "long is " << sizeof (long) << "bytes." << endl << endl;
-
- cout << "Bits per byte = " << CHAR_BIT << endl << endl;
-
- cout << "Maximum values:" << endl;
- cout << "int: " << INT_MAX << endl;
- cout << "short: " << SHRT_MAX << endl;
- cout << "long: " << LONG_MAX << endl;
- cout << "char: " << CHAR_MAX << endl;
- cout << "signed char: " << SCHAR_MAX << endl;
- cout << "unsigned int: " << UINT_MAX << endl;
- cout << "unsigned short:" << USHRT_MAX << endl;
- cout << "unsigned long: " << ULONG_MAX << endl;
- cout << "unsigned char: " << UCHAR_MAX << endl << endl;
-
- cout << "Minimum values:" << endl;
- cout << "int: " << INT_MIN << endl;
- cout << "short: " << SHRT_MIN << endl;
- cout << "long: " << LONG_MIN <<endl;
- cout << "char: " << CHAR_MIN <<endl;
- cout << "signed char: " << SCHAR_MIN <<endl;
-
- system("pause");
-
- return 0;
- }
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/pass86/archive/2006/07/27/984708.aspx
posted on 2010-05-26 23:19
付翔 阅读(435)
评论(0) 编辑 收藏 引用 所属分类:
ACM 数据结构