C语言求两个整数中的较大者

C语言求两个整数中的较大者

函数定义法:先定义函数,再调用函数。

#include<stdio.h>
int max(int a,int b)//定义函数max 
{
    
    
	int c;
	if(a>b) c=a;
	else c=b;
	return (c);
 } 
void main()
{
    
    
	int x,y,z;
	printf("输入两个整数:");
	scanf("%d,%d",&x,&y);
	z=max(x,y);//调用max函数 
	printf("较大的整数是:%d\n",z);
}

运行结果:
请添加图片描述

猜你喜欢

转载自blog.csdn.net/qq_62127918/article/details/134009565