數(shù)據(jù)類型

#include "pch.h"
#include <iostream>
#include <climits>

using namespace std;
int main()
{
    bool bools = 1;
    cout << "=============bool===============" << endl;
    cout << "bool 判斷整形 :" << bools << endl;
    cout << "bool類型的長度:" << sizeof(bool) << "bytes" << endl;

    char chars[] = "-127~128";
    unsigned char uchars[] = "0~255";
    cout << "=============char===============" << endl;
    cout << "char 字符整形 :" << chars << endl;
    cout << "char類型的長度:" << sizeof(char) << "bytes"<< endl;
    cout << "unsigned char 無符號字符整形 :" << uchars << endl;
    cout << "unsigned char類型的長度:" << sizeof(unsigned char) << "bytes" << endl;
    cout << "相當(dāng)于bool類型*256" << endl;

    short shorts = SHRT_MAX;
    unsigned short ushorts = USHRT_MAX;
    cout << "=============short===============" << endl;
    cout << "short 短整形 :" << shorts << endl;
    cout << "short類型的長度:" << sizeof(short) << "bytes" << endl;
    cout << "unsigned short 無符號短整形 :" << ushorts << endl;
    cout << "unsigned short類型的長度:" << sizeof(unsigned short) << "bytes" << endl;
    cout << "相當(dāng)于char類型的平方" << endl;

    int ints = INT_MAX;
    unsigned int uints = UINT_MAX;
    cout << "=============int===============" << endl;
    cout << "int 整形 :" << ints << endl;
    cout << "int類型的長度:" << sizeof(int) << "bytes" << endl;
    cout << "unsigned int 無符號整形 :" << uints << endl;
    cout << "unsigned int類型的長度:" << sizeof(unsigned int) << "bytes" << endl;
    cout << "相當(dāng)于short類型的平方" << endl;

    long longs = LONG_MAX;
    unsigned long ulongs = ULONG_MAX;
    cout << "=============long==============="<< endl;
    cout << "long 長整形 :" << longs << endl;
    cout << "long類型的長度:" << sizeof(long) << "bytes" << endl;
    cout << "unsigned long 無符號長整形 :" << ulongs << endl;
    cout << "unsigned long類型的長度:" << sizeof(unsigned long) << "bytes" << endl;
    cout << "與int 相等" << endl;

    long long Tlongs = LLONG_MAX;
    unsigned long long uTlongs = ULLONG_MAX;
    cout << "=============long long===============" << endl;
    cout << "long long 長整形 :" << Tlongs << endl;
    cout << "long long 類型的長度:" << sizeof(long long) << "bytes" << endl;
    cout << "unsigned long long 無符號長整形 :" << uTlongs << endl;
    cout << "unsigned long long 類型的長度:" << sizeof(unsigned long long) << "bytes" << endl;
    cout << "相當(dāng)于int 或者 long 的平方" << endl;

    float floats = FLT_MAX;
    cout << "=============float===============" << endl;
    cout << "float浮點(diǎn)型 :" << floats << endl;
    cout << "float類型的長度:" << sizeof(float) << "bytes" << endl;

    double doubles = DBL_MAX;
    cout << "=============float===============" << endl;
    cout << "double浮點(diǎn)型 :" << doubles << endl;
    cout << "double類型的長度:" << sizeof(double) << "bytes" << endl;

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容