#include <stdio.h> #include <stdlib.h> int a = 1; void test(){ int a = 2; a += 1; } int main(){ test(); printf("%d\n", a); return 0; }
1
2
3
4
//这个样子也可以 #include<stdio.h> #include<stdlib.h> int a=1; int test() { int a=2; a+=1; return a; } int main() { test(); printf("%d\n",test()); system("pause"); return 0; }
函数内屏蔽全局变量
这道题你会答吗?花几分钟告诉大家答案吧!
扫描二维码,关注牛客网
下载牛客APP,随时随地刷题