#include <iostream.h>main(){ int i; int j; cout<<"i in outer block is"<<i<<"\n"; cout<<"j in outer block is"<<j<<"\n"; cout<<"k in outer block is"<<k<<"\n"; { int k; cout<<"i in inner block is"<<i<<"\n"; cout<<"j in inner block is"<<j<<"\n"; cout<<"k in inner block is"<<k<<"\n"; } cout<<"i back in outer block is"<<i<<"\n"; cout<<"j back in outer block is"<<j<<"\n"; cout<<"k back in outer block is"<<k<<"\n";}这样运行出错改成这样#include <iostream.h>main(){ int i; int j; int k; cout<<"i in outer block is"<<i<<"\n"; cout<<"j in outer block is"<<j<<"\n"; cout<<"k in outer block is"<<k<<"\n"; { cout<<"i in inner block is"<<i<<"\n"; cout<<"j in inner block is"<<j<<"\n"; cout<<"k in inner block is"<<k<<"\n"; } cout<<"i back in outer block is"<<i<<"\n"; cout<<"j back in outer block is"<<j<<"\n"; cout<<"k back in outer block is"<<k<<"\n";}可以运行,但为什么不是书上的结果啊?书上的是8886 18 0我的结果是2130567168 4246980 4248082
又是个c++入门问题
答案:1 悬赏:50 手机版
解决时间 2021-05-03 09:48
- 提问者网友:活着好累
- 2021-05-03 05:47
最佳答案
- 五星知识达人网友:想偏头吻你
- 2021-05-03 06:44
这个结果是随机值,因为你没有初始化,所以取到的值很可以是以前用过的残留数据,即脏数据,所以估计这次和下次的运行结果都不一样!
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯