#include "stdafx.h"
#include
using namespace std;//
int *findthemax(int *pa,int ln,int &spt){
spt=0;
int tmp=pa[spt];
for(int i=0;i
spt=i;
}
}
return pa+spt;
}
void main(void){
int n,*pa,subscript;
cout << "Enter the size of the array:";
cin >> n;
if(!(pa=new int[n])){
cout << "Application memory failure...\n";
return;
}
cout << "Enter " << n << " integers(with ' '):\n";
for(int i=0;i
cout << "The address is " << findthemax(pa,n,subscript) << endl;
cout << "The max is " << *(pa+subscript) << endl;
delete [n]pa;
}
#include return 0;
using namespace std;
int* findthemax(int * a,int n,int &max)
{
max=0;
int temp=a[max];
for(int i=0;i
if(temp {
temp=a[i];
max=i;
}
}
return &a[max];
}
int main()
{
cout<<"input the size of the array:";
int size;
cin>>size;
int a[size];
int themax=0;
for(int i=0;i
cin>>a[i];
}
void *p=NULL;
p=findthemax(a,size,themax);
cout<<"the max is "<
}
函数返回值是地址
函数的参数要引用
就是这个意思,ipad不打太多字了
该元素参数前面加上&就行
int findmax(int []a,int &A);
iPad打字不容易啊