首页 > 试题广场 >

有容乃大

[编程题]有容乃大
  • 热度指数:90900 时间限制: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.
#include <stdio.h>

int main() {
    printf("The size of short is %d bytes.\n",sizeof(short));
    printf("The size of int is %d bytes.\n",sizeof(int));
    printf("The size of long is %d bytes.\n",sizeof(long));
    printf("The size of long long is %d bytes.\n",sizeof(long long));
    return 0;
}
发表于 2024-10-01 17:26:42 回复(0)
#include <stdio.h>

int main() {
    printf("The size of short is %d bytes.\n",sizeof(short));
    printf("The size of int is %d bytes.\n",sizeof(int));
    printf("The size of long is %d bytes.\n",sizeof(long));
    printf("The size of long long is %d bytes.\n",sizeof(long long));
    return 0;
}
发表于 2023-06-25 20:41:15 回复(0)
#include<stdio.h>
int main()
{
    printf("The size of short is %d bytes.\n",sizeof(short));
    printf("The size of int is %d bytes.\n",sizeof(int)) ;
    printf("The size of long is %d bytes.\n",sizeof(long));
    printf("The size of long long is %d bytes.\n",sizeof(long long));
    return 0;
}
发表于 2022-03-14 21:20:53 回复(0)
#include <stdio.h>
int main()
{
    printf("The size of short is %d bytes.\n", sizeof(short));
    printf("The size of int is %d bytes.\n", sizeof(int));
    printf("The size of long is %d bytes.\n", sizeof(long));
    printf("The size of long long is %d bytes.", sizeof(long long));
    return 0;
}

用sizeof来计算字节空间,在%d表达出来就可以
发表于 2022-02-11 17:12:17 回复(0)
#include<stdio.h>
int main(void){
    printf("The size of short is %d bytes.\n", sizeof(short));
    printf("The size of int is %d bytes.\n", sizeof(int));
    printf("The size of long is %d bytes.\n", sizeof(long));
    printf("The size of long long is %d bytes.\n", sizeof(long long));
    
    return 0;
}
考察sizeof的使用,基础知识,输出的内容最好是复制题目中的,以免打错,然后把?改成%d,printf里面再跟sizeof表达式参数即可
发表于 2022-01-27 03:51:48 回复(0)
#include<stdio.h>
int main()
{
    printf("The size of short is %d bytes.\n",sizeof(short));
    printf("The size of int is %d bytes.\n",sizeof(int));
    printf("The size of long is %d bytes.\n",sizeof(long));
    printf("The size of long long is %d bytes.\n",sizeof(long long));

    return 0;


发表于 2022-01-03 12:38:13 回复(0)
sizeof为计算字节数。
发表于 2021-12-20 10:31:06 回复(0)
int main()
{
    printf("The size of short is %d bytes.\n", sizeof(short));
    printf("The size of int is %d bytes.\n", sizeof(int));
    printf("The size of long is %d bytes.\n", sizeof(long));
    printf("The size of long long is %d bytes.\n", sizeof(long long));
    return 0;
    
}

发表于 2021-11-22 17:54:59 回复(0)
#include <stdio.h>

int main(void)
{
    printf("The size of short is %zu bytes.\n", sizeof(short));
    printf("The size of int is %zu bytes.\n", sizeof(int));
    printf("The size of long is %zu bytes.\n", sizeof(long));
    printf("The size of long long is %zu bytes.\n", sizeof(long long));
    
    return 0;
}
发表于 2021-11-20 17:11:21 回复(0)
#include <stdio.h>
int main()
{
    printf("The size of short is %d bytes.\n",sizeof(short));
    printf("The size of int is %d bytes.\n",sizeof(int));
    printf("The size of long is %d bytes.\n",sizeof(long));
    printf("The size of long long is %d bytes.\n",sizeof(long long));
}
发表于 2021-11-16 16:49:02 回复(0)
#include <stdio.h>
int main()
{
   printf("The size of short is %d bytes.\n",sizeof(short));
    printf("The size of int is %d bytes.\n",sizeof(int));
    printf("The size of long is %d bytes.\n",sizeof(long));
    printf("The size of long long is %d bytes.\n",sizeof(long long));
    return 0;
}
发表于 2021-09-16 01:00:53 回复(0)
#include "stdio.h"
int main()
{
    int a, b, c,d;
    a = sizeof(short);
    b = sizeof(int);
    c = sizeof(long);
    d = sizeof(long long);
    printf("The size of short is %hd bytes.\n", a);
    printf("The size of int is %d bytes.\n", b);
    printf("The size of long is %d bytes.\n", c);
    printf("The size of long long is %d bytes.\n", d);
    return 0;
}
发表于 2021-09-05 16:17:09 回复(2)
//用c语言

#include <stdio.h>
 
int main(void)
{
    printf("The size of short is %hd bytes.\n", sizeof(short));
    printf("The size of int is %d bytes.\n", sizeof(int));
    printf("The size of long is %ld bytes.\n", sizeof(long));
    printf("The size of long long is %lld bytes.\n", sizeof(long long));
    return 0;
}
发表于 2021-07-17 11:14:44 回复(1)