美文网首页
Chapter 3 处理数据

Chapter 3 处理数据

作者: MomToldYouSo | 来源:发表于2018-03-15 16:10 被阅读0次

变量

整型数及相关

查询intlongshort的长度:

#include <climits>
int n_int = INT_MAX;
short n_short = SHRT_MAX;
long n_long = LONG_MAX;
long long n_llong = LLONG_MAX;

sizeof variable返回的是字节长度:

cout << "short is " << sizeof n_short << " bytes." << endl;
// short is 2 bytes.
cout << "int is " << sizeof(int) << " bytes." << endl;
// int is 4 bytes.

无符号变量unsigned int

cout << "Enter your agent code:________\b\b\b\b\b\b\b\b";
long code;
cin >> code;
// 将在打印完下划线后退回第一个下划线前等待输入

布尔值

只有零值才为false,其他均为true

bool start = -100; // start = true
bool end = 0; // end = false

const限定符

const#define好:

  • 可以指明类型
  • 可以将常量定义限制在一定范围内
  • 可以用于更复杂的结构,如数组

浮点数

相关文章

网友评论

      本文标题:Chapter 3 处理数据

      本文链接:https://www.haomeiwen.com/subject/jzphqftx.html