面试题1:作用域

来源:互联网 发布:弹指神功打字软件 编辑:程序博客网 时间:2024/06/09 17:29
 内容来自http://topic.csdn.net/u/20110915/22/58f0894c-e125-499b-b5ab-6a6398193293.html
// Domain.cpp : Defines the entry point for the console application.//#include "stdafx.h"int a=4;int f(int n){   int t=0; static int a=5;   if(n%2)   {      int a=6;      t+=a++; //D   }   else   {      int a=7;      t+=a++;  //B:t=7   }   return t+a++; //C:t=7+5,然后a自加变成6 //E}void main(){   int s=a,i=0;  //A:a=4;   for(;i<2;i++)   {      s+=f(i); //4+f(0)+f(1)=4+7+5+f(1)   } printf("%d\n",s);}//4+7+5+6+6

原创粉丝点击