主题:求教程序错误
#include <iostream>
using namespace std;
void orderarray (int *,const int);
int *input(int &);
double calcmiddle(const int *,const int);
int main()
{
int *pintdate=NULL;
int len;
pintdate=input(len);
orderarray(pintdate,len);
double mid=calcmiddle(pintdate,len);
cout<<"The middle value: "<<mid<<endl;
delete []pintdate;
return 0;
}
int *input(int &n)
{
cout<<"Please enter the elements number: ";
while(true)
{cin>>n;
if(n>0) true;
else cout<<"error, please re-enter: ";}
int *array=new int[n];
for(int i=0;i<n;i++)
cin>>array[i];
return array;
}
void orderarry(int *array,const int n)
{
for(int j=0;j<n;j++)
{
int *p=array+1;
for(int k=j+1;k<n;k++)
if(*p<*array)
{
int temp=*array;
*array=*p;
*p=temp;
}
}
}
double calcmiddle(const int *array,const int n)
{
if(n%2)
return (double)(array[n/2]);
else
return (double)((array[n/2]+array[n/2-1])/2);
}
运行结果:
a.obj : error LNK2001: unresolved external symbol "void __cdecl orderarray(int *,int)" (?orderarray@@YAXPAHH@Z)
Debug/a.exe : fatal error LNK1120: 1 unresolved externals
谢谢[em2]