题解 | #有容乃大#

有容乃大

https://www.nowcoder.com/practice/4712159bbc15417086d40d6c6ff94fee

//方法一 直接用 sizeof 算类型长度,
//注意打印内容直接复制粘贴过来,不要自己去敲了,可能会漏掉空格或者点

// #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;
// }


//方法二 先创建4个需要计算类型的变量,再去算类型长度
#include <stdio.h>
int main()
{
    short s = 0;
    int i = 0;
    long l = 0;
    long long ll = 0;
    
    printf("The size of short is %d bytes.\n", sizeof(s));
    printf("The size of int is %d bytes.\n", sizeof(i));
    printf("The size of long is %d bytes.\n", sizeof(l));
    printf("The size of long long is %d bytes.\n", sizeof(ll));

    return 0;
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-08 11:16
点赞 评论 收藏
分享
07-07 12:47
门头沟学院 Java
码农索隆:竟然还真有卡体检报告的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务