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

求最大值和scanf函数的使用以及函数的声明

时间:2015-02-21 22:22:06      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:

/*
 ============================================================================
 Name        : MaxNumber.c
 Author      : lf
 Version     :
 Copyright   : Your copyright notice
 Description : 求最大值和scanf函数的使用以及函数的声明
 ============================================================================
 */

#include <stdio.h>
#include <stdlib.h>
//声明在main()函数之后实现的函数
int *getMaxNumber(int *a,int *b);


/**
 * scanf()函数:
 * 将由键盘输入的数据在按下回车键时将其存到指定的变量中.
 * 这些变量的地址是在编译时分配的.
 */
int main(void) {
	int x;
	int y;
	int *p;
	scanf("%d %d",&x,&y);
	//查看已经输入的数据
	printf("x=%d,y=%d\n",x,y);
	p=getMaxNumber(&x,&y);
	printf("max=%d",*p);
	return EXIT_SUCCESS;
}

int *getMaxNumber(int *a,int *b){
	int *result;
	if (*a>*b) {
		result=a;
	} else {
		result=b;
	}
	return result;
}


求最大值和scanf函数的使用以及函数的声明

标签:

原文地址:http://blog.csdn.net/lfdfhl/article/details/43899855

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