64,654
社区成员
发帖
与我相关
我的任务
分享
#include<iostream.h>
#include<stdio.h>
void maxmin(int *p , int &max , int &min)
{
int temp=*p;
int *a =&max;
int *b=&min;
for(int i=0;i<10;i++)
{
if(temp<*(p+i))
temp=*(p+i);
}
*a=temp;
int temp1=*p;
for(int k=0;k<10;k++)
{
if(temp>*(p+k))
temp=*(p+k);
}
*b=temp1;
}
int main()
{
int a[10];
for(int j=0;j<10;j++)
cin>>a[j];
int *r=a;
int max;
int min;
void maxmin(int *p , int &max , int &min);
maxmin(a,&max,&min);
printf("%d\n",max);
printf("%d\n",min);
return 0;
}
void maxmin(int *p , int &max , int &min)
{
int temp=p[0];
for(int i=0;i<10;i++)
{
if(temp<p[i])
temp=p[i];
}
max=temp;
int temp1=p[0];
for(int k=0;k<10;k++)
{
if(temp1>p[k])
temp1=p[k];
}
min=temp1;
}
int main()
{
int a[10];
for(int j=0;j<10;j++)
cin>>a[j];
int *r=a;
int max;
int min;
void maxmin(int *p , int &max , int &min);
maxmin(a,max,min);
printf("%d\n",max);
printf("%d\n",min);
system("pause");
return 0;
}