第7课 (short,int, long 和long long )

#include <iostream>

using namespace std;

int main()

{

    short n_short = SHRT_MAX;

    int n_int = INT_MAX;

    long n_long = LONG_MAX;

    long long n_llong = LLONG_MAX;

    int n(5);//另外一种赋值int n{7}

 

    cout << "short占用" << sizeof(short) << "字节" << endl;

    cout << "short最大值是:" << n_short << endl;

 

    cout << "int占用" << sizeof(int) << "字节" << endl;

    cout << "int最大值是:" << n_int << endl;

   

    cout << "long占用" << sizeof(long) << "字节" << endl;

    cout << "long最大值是:" << n_long<< endl;

 

    cout << "long long占用" << sizeof(long long) << "字节" << endl;

    cout << "long long最大值是:" << n_llong << endl;

 

    cout << "Bit per byte" << CHAR_BIT<< endl;

}

posted @ 2021-04-18 10:57  梦之心  阅读(74)  评论(0编辑  收藏  举报