VC 哪位高手帮我看看呀~~谢谢~~
#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("%d",&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[100][100];/*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 spots in order:cdef\n");
scanf("%f",&c);
scanf("%f",&d);
scanf("%f",&e);
scanf("%f",&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=0;
int column=0;
for(i=0;i<r;i++)
{
for(j=0;j<r;j++)
{
if(max<matrix[i][j])
{
max=matrix[i][j];
row=i;
column=j;
}
}
}
printf("max=%f,row=%d,column=%d\n",max,row+1,column+1);
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");
}
}
}
}
最后最大值那一块貌似没执行的说,还有您帮忙看看最后出那样的结果是对的么?