📜  门| Gate IT 2008 |第48章

📅  最后修改于: 2021-06-29 01:50:36             🧑  作者: Mango

考虑下面的C程序。它打印什么?

# include 
# define swapl (a, b) tmp = a; a = b; b = tmp
void swap2 ( int a, int b)
{
        int tmp;
        tmp = a; a = b; b = tmp;
 }
void swap3 (int*a, int*b)
{
        int tmp;
        tmp = *a; *a = *b; *b = tmp;
}
int main ()
{
        int num1 = 5, num2 = 4, tmp;
        if (num1 < num2) {swap1 (num1, num2);}
        if (num1 < num2) {swap2 (num1 + 1, num2);}
        if (num1 >= num2) {swap3 (&num1, &num2);}
        printf ("%d, %d", num1, num2);
}
 /* Add code here. Remove these lines if not writing code */ 

(A) 5、5
(B) 5、4
(C) 4、5
(D) 4、4答案: (C)
说明: “如果(num1> = num2){swap3(&num1,&num2);}”语句为true,则将执行引用调用。
这个问题的测验