首页 > 试题广场 >

有容乃大

[编程题]有容乃大
  • 热度指数:91742 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32M,其他语言64M
  • 算法知识视频讲解
确定不同整型数据类型在内存中占多大(字节),输出不同整型数据类型在内存中占多大(字节)。 

输入描述:


输出描述:
不同整型数据类型在内存中占多大(字节),具体格式详见输出样例,输出样例中的?为不同整型数据类型在内存中占的字节数。输出样例如下:
The size of short is ? bytes.
The size of int is ? bytes.
The size of long is ? bytes.
The size of long long is ? bytes.

Java中没有long long

/**
 *
 * @Title          有容乃大
 * @Description    确定不同整型数据类型在内存中占多大(字节),输出不同整型数据类型在内存中占多大(字节)。
 *
 * @author weijunfu<ijunfu @ qq.com>
 * @date 2022/03/17 23:50
 * @version 1.0.0
 *
 */

public class Main {

    public static void main(String[] args) {
        System.out.printf("The size of short is %d bytes.\n", Short.BYTES);
        System.out.printf("The size of int is %d bytes.\n", Integer.BYTES);
        System.out.printf("The size of long is %d bytes.\n", Long.BYTES);
        System.out.printf("The size of long long is %d bytes.\n", Long.BYTES);
    }
}
发表于 2022-03-17 23:54:26 回复(1)
public class Main{
    public static void main(String[] args){
        System.out.println("The size of short is " + Short.BYTES + " bytes.");
        System.out.println("The size of int is " + Integer.BYTES + " bytes.");
        System.out.println("The size of long is " + Long.BYTES + " bytes.");
        System.out.println("The size of long long is " + Long.BYTES + " bytes.");
    }
}
发表于 2021-09-26 10:57:27 回复(0)
public class Main{
    public static void main(String[] args) {
        System.out.println("The size of short is "+Short.BYTES+" bytes.");
        System.out.println("The size of int is "+Integer.BYTES+" bytes.");
        System.out.println("The size of long is "+Long.BYTES+" bytes.");
        System.out.println("The size of long long is "+ Long.BYTES+" bytes.");
    }
}

发表于 2021-09-25 17:18:17 回复(0)
注意:Java中没有long long这个数据类型。
发表于 2020-10-22 10:39:52 回复(0)

java哪有longlong。。
个人觉得java答案:

public static void main(String[] args){
        System.out.println("The size of byte is "+Byte.SIZE+" bytes.");
        System.out.println("The size of short is "+Short.SIZE+" bytes.");
        System.out.println("The size of int is "+Integer.SIZE+" bytes.");
        System.out.println("The size of long is "+Long.SIZE+" bytes.");
    }

要通过的答案:

public class Main{

    public static void main(String[] args){

        System.out.println("The size of short is 2 bytes.");
        System.out.println("The size of int is 4 bytes.");
        System.out.println("The size of long is 8 bytes.");
        System.out.println("The size of long long is 8 bytes.");
    }

}
发表于 2020-03-22 11:16:05 回复(5)
有一说一,这道题真的难顶。
发表于 2020-03-09 15:49:40 回复(0)