1.#include <stdio.h>
2.int main()
3.{
4. int a = 20;
5. int score = a + 100;
6. printf("%d\n", score);//score=120,score的作用域为3-22
7. {
8. int score = 50;
9. {
10. score = 10;
11. printf("%d\n", score);//score=10,score的作用域为7-14
12. }
13. a = 10;
14. }
15. {
16. score = a + 250;
17. int score = 30;
18. printf("%d\n", score);//30,score的作用域为15-19,在17行被重新定义
19. }
20. printf("%d\n", score);//260,score作用域为3-22,求值为16,a的作用域为3-22,在13行被定义
21. return 0;
22.}
|
|