6

简单指针实现两个数比较大小

 2 years ago
source link: https://blog.51cto.com/u_15838996/5983882
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

简单指针实现两个数比较大小

精选 原创

爱莉希雅我的最爱 2023-01-02 17:05:08 ©著作权

文章标签 指针变量 #include 文章分类 C/C++ 编程语言 阅读数205

我们要先知道指针变量的作用是储存你指定变量所在的地址。因为按照计算机规则你所定义的值会被电脑储存在一个位置,只要是位置就会有地址。

#include<stdio.h>
int main()
{
int i,r;
int *p,*t;
printf("请输入两个值");
scanf("%d %d",&i,&r);
p=&i;t=&r;
if(r>i)
{
p=&r;
t=&i;
}//这里的作用就是交换两个指针变量所储存的地址以达到交换作用
printf("i=%d,r=%d,max=%d,min=%d",i,r,*p,*t); //这里的*号就相当于通过这个地址找到了这个数据。
return 0;
}

简单指针实现两个数比较大小_指针变量
  • 收藏
  • 评论
  • 分享
  • 举报

</div


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK