[求助]c++编译通过,运行时内存不能读
求给定点的最小外接矩形顶点坐标int max(int a[],int n)
{int max,i;
max=a[i];
for(i=2;i<n;i++)
if(a[i]>max)
max=a[i];
return max;
}
int min(int a[],int n)
{int min,i;
min=a[i];
for(i=2;i<n;i++)
if(a[i]<min)
min=a[i];
return min;
}
#include<iostream>
using namespace std;
#define N 6
main()
{int x[N],y[N],maxx,maxy,minx,miny,i;
cout<<"please input x and y"<<endl;
for(i=1;i<N;i++)
{cout<<"x["<<i<<"]=";
cin>>x[i];
cout<<"y["<<i<<"]=";
cin>>y[i];
cout<<"x[i]="<<x[i]<<"\n"<<"y[i]="<<y[i]<<endl;
}
maxx=max(x,N);
minx=min(x,N);
maxy=max(y,N);
miny=min(y,N);
cout<<"最小外接矩形的四个点的坐标为:"<<endl;
cout<<"("<<minx<<","<<miny<<")"<<endl;
cout<<"("<<minx<<","<<maxy<<")"<<endl;
cout<<"("<<maxx<<","<<maxy<<")"<<endl;
cout<<"("<<minx<<","<<maxy<<")"<<endl;
system("pause");
return 0;
}
[此贴子已经被作者于2006-11-23 23:26:11编辑过]