#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
struct Point{double x,y;};
Point p[2000];
bool cmp(Point a,Point b)
{
if(a.y==b.y)
{
return a.x<b.x;
}
else return a.y>b.y;
}
bool cmp1(Point a,Point b)
{
return a.x>b.x;
}
void sort_t(Point p[],int len)
{
int yTo[2000][2];
int s,e;
double temp;
int count=0;
sort(p,p+len,cmp);
temp=p[0].y;
s=0;
yTo[count][0]=s;
for(int i=1;i<len;i++)
{
if(temp==p[i].y)
{
e=i;
yTo[count][1]=e;
}
else
{
s=i;
yTo[count++][0]=s;
temp=p[i].y;
}
}
for(int i=0;i<count;i++)
{
int j=yTo[i][0];
if(i%2==0)
{
sort(p+j,p+yTo[i][1],cmp);
}
else
{
sort(p+j,p+yTo[i][1],cmp1);
}
}
}
int main()
{
freopen("f:/in.txt","r",stdin);
freopen("f:/out.txt","w",stdout);
int count=0;
while(cin>>p[count].x>>p[count].y)
{
++count;
}
sort_t(p,count);
for(int i=0;i<count;i++)
{
cout<<p[i].x<<" "<<p[i].y<<endl;
}
return 0;
}
编译没问题 但是一运行 就会自动弹出 .exe已经停止工作 也没显示代码有错误之类 我是用CodeBlocks 运行的 运行结果如下
Compiling: F:\C++\1\1.cpp
Linking console executable: F:\C++\1\1.exe
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings
Checking for existence: F:\C++\1\1.exe
Executing: D:\Program Files\CodeBlocks/cb_console_runner.exe "F:\C++\1\1.exe" (in F:\C++\1)
Process terminated with status -1073741819 (0 minutes, 4 seconds)
哪位高手能告诉我这是什么原因