题解 | #有容乃大#
有容乃大
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; }