第二十篇:定义一个整形变量
生活随笔
收集整理的這篇文章主要介紹了
第二十篇:定义一个整形变量
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#include<iostream>
using namespace std;
int main()
{
?cout<<"int??長度為:"<<sizeof(int)<<endl;
?cout<<"short??長度為:"<<sizeof(short)<<endl;
?cout<<"long??長度為:"<<sizeof(long)<<endl;
?cout<<"unsigned short?長度為:"<<sizeof(short)<<endl;
?int a = -1;?? //定義整數型
?unsigned b = -1; //定義無符號整數型
?short int c = -3;//或者簡寫為short? 只占16位
?long int d = -4; //或者簡寫為long? 占4個字節(int在32位是4字節,64位三8字節)
?unsigned long e; //長整形
?e = a+b+c+d;? //計算一下
?cout<<"a:"<<a<<"\nb:"<<b<<"\nc:"<<c<<"\nd:"<<d<<"\ne:"<<e<<endl;
?return 0;
}
轉載于:https://www.cnblogs.com/GodPan/articles/3227581.html
總結
以上是生活随笔為你收集整理的第二十篇:定义一个整形变量的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 内网能PING通TELNET通不能访问解
- 下一篇: FORMS变量类型和消息提示