程序代码:
/*========================================
Must save as *.cpp, or else it is wrong.
Designer:suixin
QQ group: 21035626
Data:1-26-2008 15:30
========================================*/
#include <stdio.h>
#include <stdlib.h>
#define N 3
int max (int x, int y)
{
return x > y ? x : y;
}
int max (int x, int y, int z)
{
return max(max(x, y), z);
}
int max (int a, int b, int c, int d)
{
return max(max(a, b, c), d);
}
int max (int a, int b, int c, int d, int e)
{
return max(max(a, b, c, d), e);
}
int max (int a[], int len)
{
int ix = 0, max = a[ix];
for ( ; ix != len; ++ix)
{
if (a[ix] >= max)
{
max = a[ix];
}
}
return max;
}
int main()
{
//example1: maxterm in ten numbers
int a, b, c, d, e, f, g, h, i, j;
scanf("%d%d%d%d%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f, &g, &h, &i, &j);
printf("max:%d\n", max (max(a, b, c, d, e), max(f, g, h, i, j)));
//example2: maxterm in one arrary
int n[N] = {8, 9, 10};
printf("max:%d\n", max(n, N));
system("pause");
return 0;
}
[[italic] 本帖最后由 随心 于 2008-1-26 15:33 编辑 [/italic]]