#include <stdio.h>
#include <iostream>
using namespace std;
/*-------------------------------------------------------------------------
变量创建的语法:数据类型 变量名=初始值
*/
int main()
{
int a = 10;
cout << "a=" << a << endl;
system("pause");
return 0;
}
/*
-----------------------------------------------------------------------------
定义常量的两种方法:
1.#define 宏常量:#define 常量名 常量值
通常在文件上方定义,表示一个常量
2.const修饰的变量 :const 数据类型 常量名= 常量值
通常在变量定义前加关键字const,修饰改变量为常量,不可修改
*/
#define Day 7
int main()
{
//Day = 14; //错误,Day是常量,一旦修改就报错
cout << "一周共几天:" << Day << "天" << endl;
const int month = 12;
cout << "一月共几天:" << month << "天" << endl;
// month = 12;//错误,const修饰的变量也称为常量
system("pause");
return 0;
}