[C++]数据类型Ⅰ整数
#include <iostream> #include <stdio.h> using namespace std; int main() { cout << "short " << sizeof(short) << endl; cout << "unsigned short " << sizeof(unsigned short) << endl; cout << "int " << sizeof(int) << endl; cout << "unsigned int " << sizeof(unsigned int) << endl; cout << "long " << sizeof(long) << endl; cout << "unsigned long " << sizeof(unsigned long) << endl; cout << "long long " << sizeof(long long) << endl; cout << "unsigned long long " << sizeof(unsigned long long) << endl; cout << "int8_t " << sizeof(int8_t) << endl; cout << "int16_t " << sizeof(int16_t) << endl; cout << "int32_t " << sizeof(int32_t) << endl; cout << "int64_t " << sizeof(int64_t) << endl; cout << "uint8_t " << sizeof(uint8_t) << endl; cout << "uint16_t " << sizeof(uint16_t) << endl; cout << "uint32_t " << sizeof(uint32_t) << endl; cout << "uint64_t " << sizeof(uint64_t) << endl; cout << "int_least8_t " << sizeof(int_least8_t) << endl; cout << "int_least16_t " << sizeof(int_least16_t) << endl; cout << "int_least32_t " << sizeof(int_least32_t) << endl; cout << "int_least64_t " << sizeof(int_least64_t) << endl; cout << "uint_least8_t " << sizeof(uint_least8_t) << endl; cout << "uint_least16_t " << sizeof(uint_least16_t) << endl; cout << "uint_least32_t " << sizeof(uint_least32_t) << endl; cout << "uint_least64_t " << sizeof(uint_least64_t) << endl; cout << "int_fast8_t " << sizeof(int_fast8_t) << endl; cout << "int_fast16_t " << sizeof(int_fast16_t) << endl; cout << "int_fast32_t " << sizeof(int_fast32_t) << endl; cout << "int_fast64_t " << sizeof(int_fast64_t) << endl; cout << "uint_fast8_t " << sizeof(uint_fast8_t) << endl; cout << "uint_fast16_t " << sizeof(uint_fast16_t) << endl; cout << "uint_fast32_t " << sizeof(uint_fast32_t) << endl; cout << "uint_fast64_t " << sizeof(uint_fast64_t) << endl; cout << "__int64 " << sizeof(__int8) << endl; cout << "unsigned __int8 " << sizeof(unsigned __int8) << endl; cout << "__int64 " << sizeof(__int16) << endl; cout << "unsigned __int16 " << sizeof(unsigned __int16) << endl; cout << "__int64 " << sizeof(__int32) << endl; cout << "unsigned __int32 " << sizeof(unsigned __int32) << endl; cout << "__int64 " << sizeof(__int64) << endl; cout << "unsigned __int64 " << sizeof(unsigned __int64) << endl; cout << "intmax_t " << sizeof(intmax_t) << endl; cout << "uintmax_t " << sizeof(uintmax_t) << endl << endl; printf("8位有符号十进制最大值%hd", INT8_MAX); printf("\n"); printf("8位有符号十进制最小值%hd", INT8_MIN); printf("\n"); printf("16位有符号十进制最大值%d", INT16_MAX); printf("\n"); printf("16位有符号十进制最小值%d", INT16_MIN); printf("\n"); printf("32位有符号十进制最大值%ld", INT32_MAX); printf("\n"); printf("32位有符号十进制最小值%ld", INT32_MIN); printf("\n"); printf("64位有符号十进制最大值%lld", INT64_MAX); printf("\n"); printf("64位有符号十进制最小值%lld", INT64_MIN); printf("\n"); printf("8位有符号八进制最大值%08ho", INT8_MAX); printf("\n"); printf("8位有符号八进制最小值%08ho", INT8_MIN); printf("\n"); printf("16位有符号八进制最大值%016o", INT16_MAX); printf("\n"); printf("16位有符号八进制最小值%016o", INT16_MIN); printf("\n"); printf("32位有符号八进制最大值%032lo", INT32_MAX); printf("\n"); printf("32位有符号八进制最小值%032lo", INT32_MIN); printf("\n"); printf("64位有符号八进制最大值%064llo", INT64_MAX); printf("\n"); printf("64位有符号八进制最小值%064llo", INT64_MIN); printf("\n"); printf("8位有符号十六进制最大值%08hx", INT8_MAX); printf("\n"); printf("8位有符号十六进制最小值%08hx", INT8_MIN); printf("\n"); printf("16位有符号十六进制最大值%016x", INT16_MAX); printf("\n"); printf("16位有符号十六进制最小值%016x", INT16_MIN); printf("\n"); printf("32位有符号十六进制最大值%032lx", INT32_MAX); printf("\n"); printf("32位有符号十六进制最小值%032lx", INT32_MIN); printf("\n"); printf("64位有符号十六进制最大值%064llx", INT64_MAX); printf("\n"); printf("64位有符号十六进制最小值%064llx", INT64_MIN); printf("\n"); printf("\n"); printf("8位无符号十进制最大值%hd", UINT8_MAX); printf("\n"); printf("8位无符号十进制最小值%hd", 0); printf("\n"); printf("16位无符号十进制最大值%d", UINT16_MAX); printf("\n"); printf("16位无符号十进制最小值%d", 0); printf("\n"); printf("32位无符号十进制最大值%ld", UINT32_MAX); printf("\n"); printf("32位无符号十进制最小值%ld", 0); printf("\n"); printf("64位无符号十进制最大值%lld", UINT64_MAX); printf("\n"); printf("64位无符号十进制最小值%64d", 0); printf("\n"); printf("8位无符号八进制最大值%08ho", UINT8_MAX); printf("\n"); printf("8位无符号八进制最小值%08ho", 0); printf("\n"); printf("16位无符号八进制最大值%016o", UINT16_MAX); printf("\n"); printf("16位无符号八进制最小值%016o", 0); printf("\n"); printf("32位无符号八进制最大值%032lo", UINT32_MAX); printf("\n"); printf("32位无符号八进制最小值%032lo", 0); printf("\n"); printf("64位无符号八进制最大值%064llo", UINT64_MAX); printf("\n"); printf("64位无符号八进制最小值%064o", 0); printf("\n"); printf("8位无符号十六进制最大值%08hx", UINT8_MAX); printf("\n"); printf("8位无符号十六进制最小值%08hx", 0); printf("\n"); printf("16位无符号十六进制最大值%016x", UINT16_MAX); printf("\n"); printf("16位无符号十六进制最小值%016x", 0); printf("\n"); printf("32位无符号十六进制最大值%032lx", UINT32_MAX); printf("\n"); printf("32位无符号十六进制最小值%032lx", 0); printf("\n"); printf("64位无符号十六进制最大值%064llx", UINT64_MAX); printf("\n"); printf("64位无符号十六进制最小值%064x", 0); printf("\n"); system("pause"); return 0; }