#include<stdio.h>#include<limits.h>#define debug1 0 //使用debug1 必须包含limits.h#define debug2 1main(){#if debug1//signed typesprintf("signed char min = %d \n",SCHAR_MIN);printf("signed char max = %d \n",SCHAR_MAX);printf("signed short min = %d \n",SHRT_MIN);printf("signed short max = %d \n",SHRT_MAX);printf("signed int min = %d \n",INT_MIN);printf("signed int max = %d \n",INT_MAX);printf("signed long min = %ld \n",LONG_MIN);printf("signed long max = %ld \n",LONG_MAX);//unsigned typesprintf("unsigned char char max = %u \n",UCHAR_MAX);printf("unsigned char short max = %u \n",USHRT_MAX);printf("unsigned char int max = %u \n",UINT_MAX);printf("unsigned char long max = %lu \n",ULONG_MAX);#endif#if debug2/* ~0 : 数字0 的各个二进制位全部转换为1(unsigned char)~0 : 将结果转换为unsigned char 类型(unsigned short )~0>>1 : 右移一位 清除符号位(char)((unsigned char )~0>>1)) : 将其转换为char型*///signed typesprintf("signed char min = %d \n",-(char)((unsigned char )~0>>1));printf("signed char max = %d \n",(char)((unsigned char )~0>>1));printf("signed short min = %d \n",-(short)((unsigned short )~0>>1));printf("signed short max = %d \n",(short)((unsigned short )~0>>1));printf("signed int min = %d \n",-(int)((unsigned int )~0>>1));printf("signed int max = %d \n",(int)((unsigned int )~0>>1));printf("signed long min = %ld \n",-(long)((unsigned int )~0>>1));printf("signed long max = %ld \n",(long)((unsigned long )~0>>1));//unsigned typesprintf("unsigned char char max = %u \n",(unsigned char )~0);printf("unsigned char short max = %u \n",(unsigned short )~0);printf("unsigned char int max = %u \n",(unsigned int )~0);printf("unsigned char long max = %lu \n",(unsigned int )~0);#endif}
1200字范文,内容丰富有趣,写作的好帮手!