为什么max的值不是21

img

getMax中三目运算符返回的是xy的最大值又不是ab的最大值,而xy并没有产生变化

你跑一遍下面的程序:

#include <stdio.h>
int GetMax(int x,int y);
int a=10,b=20;
int main()
{
   /* 我的第一个 C 程序 */
   printf("a地址:0x%x a的值:%d\nb地址:0x%x b的值:%d\n",&a,a,&b,b);
   GetMax(a,b);
    printf("a地址:0x%x a的值:%d\nb地址:0x%x b的值:%d\n",&a,a,&b,b);
   return 0;
}
int GetMax(int x,int y) {
    a++;
    b++;
    printf("x地址:0x%x x的值:%d\ny地址:0x%x y的值:%d\n",&x,x,&y,y);
    return x>y?x:y;
}