64,632
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include <iostream>
using namespace std;
int * findmax(int *array,int size,int *index)
{
int i = 0;
for(i=0;i<size;i++)
if (array[i]<array[*index])//这里老是运行时出错,说什么冲突
*index=i;
cout<<i;
return index;
}
int _tmain(int argc, _TCHAR* argv[])
{
int a[10]={33,91,54,67,82,37,85,61,19,68};
int * maxaddr=0;
int idx = 0;
maxaddr=findmax(a,sizeof(a)/sizeof(*a),&idx);
cout<<"the index of maximum element is"<<idx<<endl
<<"the address of it is"<<maxaddr<<endl
<<"the value of it is"<<a[idx]<<endl;
system("pause");
return 0;
}