有容乃大

有容乃大

http://www.nowcoder.com/questionTerminal/4712159bbc15417086d40d6c6ff94fee

分析:

对于不同的系统和机器其对应类型的大小有所不同,sizeof运算符可以计算出当前类型的大小,故能够轻松解出本题。

题解:

#include <bits/stdc++.h>
using namespace std;

int main() {
    //使用sizeof运算符输出各种类型的大小
    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));
}

总结:

sizeof运算符的使用,确保代码能够鲁棒的在不同机器上运行。

全部评论

相关推荐

阿里巴巴各部门年终奖开奖了,有人拿到了220w
真烦好烦真烦:拿命换钱呢,公司给你220万,肯定是因为你对公司的贡献大于220万,想想要多厉害多累才能达到
投递阿里巴巴集团等公司10个岗位 >
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
03-28 13:48
hory权:校招vip纯神人了,还说自己是什么师范大学的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务