c语言中的max的用法

输入几个数,我想用max来找出最大的数,该怎么来编写?
2025-03-09 09:27:48
推荐回答(3个)
回答1:

例如3个数
int max(int a,int b,int c)
{
int x;
if(a>=b)
x=a;
else x=b;
if(c>=x)
x=c;
return x;
}
如果是很多个数,就存在数组里,然后用,冒泡/比较/快排等排序方法从大到小排列,然后找a[0]就ok了

回答2:

不知道你要表达的是不是这个意思!

#include "stdio.h"
void main(){
int max,i,a[10]={2,1,9,3,4,13,19,3,4,1};
max=a[0];
for(i=1;i<10;i++){
if(a[i]>max){
max = a[i];
}
}
printf("max=%d\n",max);
}

回答3:

用数组存这些数·~递归比较