C/C++教程

C++ short,int,long,long long整型

本文主要是介绍C++ short,int,long,long long整型,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

#include<iostream>
using namespace std;
int main() {
    //短整形short(-2^15--2^15-1)2字节 一字节=8比特15=2*8-1
    short num1 =32769;
    //整形int(-2^31--2^31-1)4字节
    int num2 = 10;
    //长整型long windows为4字节,Linux为4字节(32),8字节(64)
    long num3 = 10;//-2^31--2^31-1或-2^63--2^63-1
    //长长整形,8字节或16字节 -2^63--2^63-1或-2^127--2^127-1
    long long num4 = 10;
    cout << "num1=" << num1 << endl;
    cout << "num2=" << num2 << endl;
    cout << "num3=" << num3 << endl;
    cout << "num4=" << num4 << endl;
    system("pause");

}

这篇关于C++ short,int,long,long long整型的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!