正在加载图片...
C++语言程序设计 数据类型 型数值溢出例子 inc lude iostream using name space std int maino short int i;// signed short类型整数(-32768-32767) short unsigned int j;// unsigned short类型整数(0-65535) j=50000; i=j;/将 unsigned short赋值给 signed short变量 cout the short int is: i <endl //整型数值溢出 cout The short unsigned int is:<< jendl return 0: x The short int is: -15536 The short unsigned int is: 50000C++语言程序设计 16 数据类型 ——整型数值溢出例子 #include <iostream> using namespace std; int main() { short int i; //signed short类型整数 (-32768-32767) short unsigned int j;//unsigned short类型整数(0-65535) j = 50000; i = j;//将unsigned short赋值给signed short变量 cout <<" The short int is:"<< i <<endl; //整型数值溢出 cout <<" The short unsigned int is:"<< j<<endl; return 0; } The short int is:-15536 The short unsigned int is:50000
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有