static int 输出
来源:互联网 发布:淘宝店铺的客服电话 编辑:程序博客网 时间:2024/06/05 11:14
下面程序会输出什么:
static int a=1;void fun1(void){ a=2; }void fun2(void){ int a=3; }void fun3(void){ static int a=4; }int main(int argc,char** args){ printf(“%d”,a); fun1( ); printf(“%d”,a); fun2( ); printf(“%d”,a); fun3( ); printf(“%d”,a); }
正确答案: B 你的答案: C (错误)
1 2 3 4
1 2 2 2
1 2 2 4
1 1 1 4
- 添加笔记
- 求解答(23)
- 收藏
- 纠错
选B
printf(“%d”,a); //输出全局静态变量,所以输出1
fun1( ); //a=2所以会修改全局静态变量,输出2
printf(“%d”,a);
fun2( ); //int a=3是在func2里的局部变量,所以调用结束就释放了,不影响全局的a值,所以输出2
printf(“%d”,a);
fun3( ); //也是局部变量,虽然是静态的但是不会影响全局a的值,仍然输出2
printf(“%d”,a);
0 0
- static int 输出
- static int 和 int 区别
- static int
- static int 与 int 的区别
- public static final int a;
- static int net_check_prereq (proto_t protocol)
- Qt int QApplication::exec() [static]
- static int LinesCount(string str)
- int转化为char输出
- queue vector <int>倒序输出
- win32的输出int类型
- C++输出int,float,double
- public static Bitmap zoomIn(Bitmap bitmap, int maxW, int maxH)
- public static Bitmap createScaledBitmap(Bitmap unscaledBitmap, int dstWidth, int dstHeight,
- 详解public static int parseInt(String s, int radix)
- const 成员 static 成员 const static int 成员初始化
- const 成员 static 成员 const static int 成员初始化
- private static int num=0;
- sed命令
- socket通讯,客户端获取数据丢失问题
- ubuntu10.04 编译安装gcc-5.3.0
- 在android中使用OkHttp框架处理网络请求
- 【BZOJ】2005 [Noi2010]能量采集
- static int 输出
- redis 配置文件
- 推荐大家使用的CSS书写规范、顺序
- 2016 Multi-University Training Contest 1 1002 Chess
- 视差滚动Parallax
- Redis 介绍
- Intent 之系统Intent<一>
- generateParenthesis——leetcode
- 83. Remove Duplicates from Sorted List