做題目遇到傳址、傳值呼叫,只要題目難一點就會一直卡住。
請問下面兩題如何計算?
1.VB
Private Sub Form_Activate( )
DIM X as Integer
X=3
Call F1(X)
Debug.Print(X)
End Sub
Sub F1( ByRef X As Integer )
Call T2( X=X+X , X , X )
End Sub
Sub T2(ByRef A As Integer ,ByVal B As Integer , ByRef C As Integer )
A = A + 1 : B = B + 2 : C = A + B * C
End Sub.
請問最後印出?
2.C/C++
int f1(int y){y=y+1; return y;}
int f2(int &y){y=y+1; return y;}
int f3(int *y){*y=*y+1; return *y;}
void main(){
int a,b,c,d,x=1;
a=f1(x);
b=f2(x);
c=f3(&x);
d=x++;
}
請問d值?