| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
请高手帮我看一下这是个什么错误,谢谢!小弟用C++写的程序,用MinGw Developer编译的
对那些测试数据都能过,除了一组:
input
10
35 500000000
200 500000000
0 0
总是会提示下面这句话:
This application has requested the Runtime to terminate it in an unuaual way. Please contact the application's support team for more information.
本来以为是我的算法有问题,后来我把500000000改小,改到10000就能得到正确结果,所以我现在也不知道哪里出错了
程序中的变量都是用的int型,是因为数据太大了,存不下吗?可是我改成long和__int64,还是出现同样的问题
下面是代码,请高手帮我看一下吧,因为是菜鸟,算法没有任何优化,可能还有些罗嗦,不要笑我,谢谢!
#include<iostream>
#include<cmath>
using namespace std;
void edgedetect(int hang[],int len,int width)
{
int i,j;
int line=len/width;
int image[line][width];
for( i=0; i<line; i++)
{
for( j=0; j<width; j++)
{
image[i][j]=hang[i*width+j];
}
}
int buff[line+2][width+2];
for( i=0; i<line; i++)
{
for( j=0; j<width; j++)
{
buff[i+1][j+1]=image[i][j];
}
}
for( j=1; j<=width; j++)
{
buff[0][j]=image[0][j-1];
buff[line+1][j]=image[line-1][j-1];
}
for( i=0; i<line+2; i++)
{
buff[i][0]=buff[i][1];
buff[i][width+1]=buff[i][width];
}
for( i=1; i<=line; i++)
{
for( j=1; j<=width; j++)
{
int max=0;
if(abs(buff[i-1][j-1]-buff[i][j]) > max)
max=abs(buff[i-1][j-1]-buff[i][j]);
if(abs(buff[i-1][j]-buff[i][j]) > max)
max=abs(buff[i-1][j]-buff[i][j]);
if(abs(buff[i-1][j+1]-buff[i][j]) > max)
max=abs(buff[i-1][j+1]-buff[i][j]);
if(abs(buff[i][j-1]-buff[i][j]) > max)
max=abs(buff[i][j-1]-buff[i][j]);
if(abs(buff[i][j+1]-buff[i][j]) > max)
max=abs(buff[i][j+1]-buff[i][j]);
if(abs(buff[i+1][j-1]-buff[i][j]) > max)
max=abs(buff[i+1][j-1]-buff[i][j]);
if(abs(buff[i+1][j]-buff[i][j]) > max)
max=abs(buff[i+1][j]-buff[i][j]);
if(abs(buff[i+1][j+1]-buff[i][j]) > max)
max=abs(buff[i+1][j+1]-buff[i][j]);
image[i-1][j-1]=max;
hang[(i-1)*width+j-1]=max;
}
}
}
struct Node
{
int elm;
int count;
};
int main()
{
Node node;
Node pic[100];
int width;
cin>>width;
while(width != 0)
{
int k=0;
int len=0;
for( int l=0; ; l++)
{
cin>>node.elm>>node.count;
if(node.elm==0 && node.count==0)
break;
else
{
pic[k].elm=node.elm;
pic[k].count=node.count;
k++;
}
}
int i,j;
for( i=0; i<k; i++)
{
len=len+pic[i].count;
}
int *hang=new int[len];
int m=0;
for( i=0; i<k; i++)
{
for( j=0; j<pic[i].count; j++)
{
hang[m]=pic[i].elm;
m++;
}
}
edgedetect(hang,len,width);
cout<<width<<endl;
int count=1;
if(hang[0]!=hang[1])
cout<<hang[0]<<" "<<count<<endl;
else
{
for(i=1;i<len;i++)
{
if(hang[i-1]==hang[i])
{
count++;
continue;
}
if(hang[i-1]!=hang[i])
{
cout<<hang[i-1]<<" "<<count<<endl;
count=1;
}
}
if(hang[len-1]==hang[len-2])
{
cout<<hang[len-1]<<" "<<count<<endl;
}
else
{
cout<<hang[len-1]<<" "<<1<<endl;
}
}
cout<<0<<" "<<0<<endl;
delete [] hang;
cin>>width;
}
cout<<"0"<<endl;
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator