A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© chuanzhang 中级黑马   /  2016-2-22 20:25  /  601 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

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.}

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马