首页 > 试题广场 >

给出以下程序的执行结果。 #include void m

[问答题]
给出以下程序的执行结果。
#include <stdio.h>
void main()
{
    int *p1,*p2,*p;
    int a=10,b=12;
    p1=&a;p2=&b;
    if (a<b)
    {
        p=p1;p1=p2;p2=p;
    }
    printf("%d,%d,",*p1,*p2);
    printf("%d,%d\n",a,b);
}

推荐
首先让p1指向a,p2指向b,a<b成立,交换p1和p2,即p2指向a,p1指向b。本题答案为12,10,10,12。
发表于 2018-05-07 10:52:30 回复(0)
交换指向。12 10 10 12
发表于 2020-03-02 16:50:52 回复(0)