#include <iostream>
using namespace std; int main()
{
{
int x=1;
cout << x << endl;
{
cout << x << endl;
int x=2;
cout << x <<endl;
{
cout << x <<endl;
int x=3;
cout << x <<endl;
}
cout << x <<endl;
}
cout << x << endl;
}
return 0;
}

输出结果 1 1 2 2 3 2 1

#include <iostream>
using namespace std; int main()
{
{
int x1=1;
cout << x1 << endl;
{
cout << x1 << endl;
int x2=2;
cout << x2 <<endl;
{
cout << x2 <<endl;
int x3=3;
cout << x3 <<endl;
}
cout << x2 <<endl;
}
cout << x1 << endl;
}
return 0;
}

输出结果 1 1 2 2 3 2 1 

/*
* 在第一例每个语句块中,虽然变量名都一样,但是int x= ;之后x就变成另外一个变量了
* 且生存周期仅限于当前的语句块中
*/

最新文章

  1. 【转】Python练习,网络爬虫框架Scrapy
  2. Maven打包跳过测试
  3. FMDB处理动态插入语句
  4. SimpleDateFormat出错
  5. Xcode 的正确打开方式——Debugging(转载)
  6. MVC神韵---你想在哪解脱!(十三)
  7. mysql与java数据类型对照
  8. JAVA对数据库进行操作,实现数据库中数据的插入,查询,更改,删除操作
  9. peoplesoft function PSTREENODE 通过 deptid 获得部门树 一级部门 名称
  10. 496. Next Greater Element I
  11. SQL Server 2016 行级别权限控制
  12. JQuery基础知识学习1
  13. 将nginx永久加入到系统环境变量
  14. Winscp使用sudo user登录
  15. See you~ HDU1892
  16. [LeetCode] 10. Regular Expression Matching ☆☆☆☆☆
  17. 丢弃昂贵的Detours Professional 3.0,使用免费强大的EasyHook
  18. docker发布spring cloud应用
  19. thinkphp控制器的使用
  20. render 的执行流程

热门文章

  1. IE和火狐 差异
  2. LepideMigrator for Documents Step by Step
  3. myEclipse下安装SVN插件
  4. hdu 2061
  5. Add a stylesheet link programmatically in ASP.NET
  6. ————————————————————————————杭电ACM————————————————X-POWER————————————————————————————————
  7. UVA11149 矩阵快速幂
  8. 7、C#基础整理(类)
  9. 微信 关闭手机微信内置浏览器的js
  10. windows系统mysql定时自动备份