您的位置:首页 > 编程语言 > C语言/C++

第1周 《C语言及程序设计》实践项目1——指针及其运算

2016-04-01 11:36 106 查看

【程序阅读题】

写出以下程序运行的结果,上机对照结果后,解释其过程。(注意用手画内存变化过程,而不要仅凭大脑思考。)

[cpp]
view plain
copy
print?





#include <stdio.h> int main() { int *p1,*p2,*p; int a=5,b=8; p1=&a; p2=&b; if(a<b) { p=p1; p1=p2; p2=p; } printf("%d,%d\n",*p1,*p2); printf("%d,%d\n",a,b); return 0; }

#include <stdio.h>
int main()
{
int *p1,*p2,*p;
int a=5,b=8;
p1=&a;
p2=&b;
if(a<b)
{
p=p1;
p1=p2;
p2=p;
}
printf("%d,%d\n",*p1,*p2);
printf("%d,%d\n",a,b);
return 0;
}


附:阅读参考

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: