码迷,mamicode.com
首页 > 其他好文 > 详细

两个数的交换

时间:2016-03-19 06:26:53      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:please   number   return   

方法一:使用函数实现两个数的交换

#include<stdio.h>
int fun(int *a,int *b)
{
	int tmp;
	tmp=*a;
	*a=*b;
	*b=tmp;
}
int main()
{
	int x,y;
	printf("please input two number:\n");
	scanf("%d %d",&x,&y);
	printf("x=%d,y=%d\n",x,y);
	fun(&x,&y);
	printf("x=%d,y=%d\n",x,y);
	return 0;
}

2.

本文出自 “sunshine225” 博客,请务必保留此出处http://10707460.blog.51cto.com/10697460/1752766

两个数的交换

标签:please   number   return   

原文地址:http://10707460.blog.51cto.com/10697460/1752766

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!