我写一个化三角矩阵的c程序运行时出现:
Unhandled exception  in (...).exe: 0xc0000005: Access Violation
这个是怎么回事啊?
#include<stdio.h>
/***//************
*  swap: exchang the to paraments
******************************/
void swap(double & p1, double & p2)
{
 double temp;
 temp=p1;
 p1=p2;
 p2=temp;
}
/***//***********************
*   消元
**********************************/
void XiaoYuan(double  a[][5], int size,double *  detA, int start)
{
 int i,j;
 double L[10];
 for(i=start+1;i<size;i++)
 {
  a[i][start]=a[i][start+1]/a[start][start];
  for(j=start+1;j<=size;j++)
  {
   a[i][j]=a[i][j]-L[i]*a[start][j];
   
  }
  *detA=a[start][start]*(*detA);
 }
}
/**//**********************************************************
*  transform the given matrix a[][] to a up_triangel matrix     *
* a[][] 系数矩阵,带等式右边b         *
*  size: 系数矩阵的行数           *
*  detA: 系数矩阵的行列式          *
*  e 为最小可分辨的值  
*  完成返回1,矩阵非奇异返回0         *
******************************************************************/
int  Tran_Up_Triangel(double a[][5],int size, double * detA, double e)
{
 int k=0;
 int i=0;
 int l=0;
 int j=0;
 for(k=0;k<size-1;k++)
 {
  for(i=k+1,l=k;i<size;i++)
  {
   if(a[l][k]>a[i][k])
    l=i;
  }
  if(a[l][k]<e&&a[l][k]>(-1)*e)
  {
   detA=0;
   return 0;
  }
  else
  {
   for(j=k;j<=size;j++)
   {
    swap(a[k][j],a[l][j]);
    * detA=(-1)*(*detA);
    XiaoYuan(a,size,detA,k);
   }
   if(a[size-1][size-1]<e&&a[size-1][size-1]>(-1)*e)
   {
    detA=0;
    return 0;
   }
   else
   {
    *detA=a[size-1][size-1]*(*detA);
   }
  }
 }
 return 1;
}
/**************************/
void print_array(double array[][5],int size)
{
 int i,j;
 for(i=0;i<size-1;i++)
 {
  for(j=0;j<size;j++)
  {
   printf(" %f", array[i][j]);
  }
  printf("\n");
 }
}
#include<stdio.h>
#include"Subfun.h"
#include <stdlib.h>
/**//********************************
*   test_main                        *
*   for  testing                           *
************************************/
void main()
{
 double a[4][5];
 int n=4;
 double e=0.02;
 double detA=0;
 int i,j;
 for (i=0;i<=n;i++)
  for (j=0;j<=n+1;j++)
   a[i][j]=(float)rand()/100.0; 
 for (i=1;i<=n;i++)
 { 
  for (j=1;j<=n;j++) printf("%8.4f ",a[i][j]);
  printf("\n");
 }
 if(Tran_Up_Triangel(a, n,& detA,e)==1)
 {
  print_array(a,n); 
 }



 
											





 
	    

 
	
 
											
