不知道对不对,请各位请教!
#include<stdio.h>
int max_search(int a[],int n)
{int i,j=0;
a[j]=a[0];
for(i=1;i<n;i++)
if(a[i]>a[j])j=i;
return(a[j]);
}
int main(void)
{int max_search(int a[],int n);
int a[20],*p1,*p2,n,i=0;
p1=p2=&a[0];
printf("Please enter the numbers:\n");
while(scanf("%d",&a[i])!=EOF)
i++;
p2=&a[i];
n=p2-p1;
printf("\nThe max is :%d\n",max_search(p1,n));
}
[此贴子已经被作者于2004-12-10 17:05:09编辑过]
欢迎光临 编程论坛 (https://bbs.bccn.net/) | Powered by Discuz! 6.1.0 |