hello guys
i wrote a program in dev cpp and when i compile it with 0 warnings or error
the program doesnt run for me
in addition when i debug this program it wrote to me:
"An access violation (segmentation fault) raised in program"
what is the problem?
insert
Code:
"
int path(int* b,int n);
int findmin(int* board,int n);
#include <stdio.h>
#include <stdlib.h>
int main()
{
int b[15]={3,4,5,5,6,9,9,8,5,4,7,5,3,1,2};
int n=5,p;
p=path(b+14,n);
printf("%d",p);
system("pause");
return 0;
}
int path(int* b,int n)
{
int m=0;
if(n==1){return *b;}
m=findmin(b,n);
return (m+path(b-n,n--));
}
int findmin(int* board,int n)
{
int i=0,min=0;
for(i=n;i>0;i--)
{
if(board[i]>min)
{
min=board[i];
}
}
return min;
}
"
thanks