VC++6.0 运行提示应用程序出错
#include <stdio.h>#include <stdlib.h>
void main()
{
int r; /*the approximate length of probable crime scope */
int x1; /*the number of commited crime spots*/
float c,d,e,f;/*probability of the spot weighed by distance*/
int i,j,k;/*loop control variable*/
printf("Please input the approximate length(integer) of probable crime scope:\n");
int ret;
ret=scanf("%f",&r);
if (ret==0)
{
printf("Input r data type error!\n");
fflush(stdin);
}
else if(ret==EOF)
{
printf("Input r failure occures!\n");
}
else
{
printf("Please input the number of commited crime spots:(<100)");
int ret2;
ret2=scanf("%d",&x1);
if (ret2==0)
{
printf("Input x1 data type error!\n");
fflush(stdin);
}
else if(ret2==EOF)
{
printf("Input x1 failure occures!\n");
}
else if(x1>=100)
{
printf("too large!!!x1 can't be larger than 100!");
}
else
{
int a[100];
int b[100];
printf("Please input the modified abscissa in order:\n");
for(i=0;i<x1;i++)
{
scanf("%d",&a[i]);
}
printf("Please input the modified ordinates in order:\n");
for(j=0;j<x1;j++)
{
scanf("%d",&b[j]);
}
float matrix[1000][1000];/*store the probabilities of each spot*/
for(i=0;i<r;i++)
{
for(j=0;j<r;j++)
{
for(k=0;k<x1;k++)
{
if((i==a[k])&&(j==b[k]))
{
matrix[i][j]=1;
}
else
{
matrix[i][j]=0;
}
}
}
}
printf("Enter the probabilities of the spotsin order like this:c,d,e,f\n");
scanf("%f,%f,%f,%f",&c,&d,&e,&f);
for(i=0;i<x1;i++)
{
for(j=0;j<r;j++)
{
for(k=0;k<r;k++)
{
if((a[i]-j<=3)&&(a[i]-j>=-3)&&(b[i]-k<=3)&&(b[i]-k>=-3))
{
matrix[j][k]+=c;
}
else if((a[i]-j<=6)&&(a[i]-j>=-6)&&(b[i]-k<=6)&&(b[i]-k>=-6))
{
matrix[j][k]+=d;
}
else if((a[i]-j<=9)&&(a[i]-j>=-9)&&(b[i]-k<=9)&&(b[i]-k>=-9))
{
matrix[j][k]+=e;
}
else if((a[i]-j<=12)&&(a[i]-j>=-12)&&(b[i]-k<=12)&&(b[i]-k>=-12))
{
matrix[j][k]+=f;
}
}
}
}
float max=matrix[0][0];
int row,column;
for(i=0;i<r;i++)
{
for(j=0;j<r;j++)
{
if(max<matrix[i][j])
{
max=matrix[i][j];
row=i+1;
column=j+1;
}
}
}
printf("max=%f,row=%d,column=%d\n",max,row,column);
printf("all probabilities within the crime scope is like this:\n");
for(i=0;i<r;i++)
{
for(j=0;j<r;j++)
{
printf("%5.4f ",matrix[i][j]);
}
printf("\n");
}
}
}
}
提示的错误为:
应用程序发生异常 unknown software exception (0xc00000fd),位置为0x00401cd7