/*lesson 5*/ #include <iostream> #include <string>
using namespace std;
int main() { ?? ?string type = "类型占用的字节数 = ";?? ??? ??? ??? ??? ?//字符串"类型"声明
?? ?cout << "char"?? ??? ??? ?<< type << sizeof(char)?? ??? ??? ?<< endl; ?? ?cout << "short"?? ??? ??? ?<< type << sizeof(short)?? ??? ?<< endl; ?? ?cout << "int"?? ??? ??? ?<< type << sizeof(int)?? ??? ??? ?<< endl; ?? ?cout << "long"?? ??? ??? ?<< type << sizeof(long)?? ??? ??? ?<< endl; ?? ?cout << "float"?? ??? ??? ?<< type << sizeof(float)?? ??? ?<< endl; ?? ?cout << "double"?? ??? ?<< type << sizeof(double)?? ??? ?<< endl; ?? ?cout << "long double"?? ?<< type << sizeof(long double)?? ?<< endl; ?? ?cout << endl;?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?//换行
?? ?int A = 255; ?? ?cout << "变量A = " << A << endl; ?? ?cout << "十六进制输出 =" << hex << A << endl; ?? ?cout << "八进制输出 =" << oct << A << endl; ?? ?cout << "十进制输出 =" << dec << A << endl; ?? ?cout << endl;?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?//换行
?? ?system("pause");?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?//程序暂停
?? ?return 0; }
运行结果:
?
|