vc 与 tc 中关于头文件的区别 ???
# include < stdio.h># include <malloc.h>
# include <string.h>
int main ( void)
{
int delta (int n) ;
int malloc() ;
int n ;
printf (" set n please \n");
scanf ("%d" ,&n);
delta(n) ;
getchar();
return 0 ;
}
int delta (int n)
{
int i, j , no , num ,max ;
int *mtrx ;
max = n * n ;
mtrx = malloc(max + max ) ;// 此处总是报错 , 我使用 vc 编辑的 ,请问怎么改啊 ?????
for (i = 0 ; i < n ; i ++)
{
for (j = 0 ; j <= 1 ; j ++)
{
if ( i < 1 )
{
mtrx[0] = 1 ;
}
else
{
no = i * n + j ;
if ( j == 0 || j ==i)
{
num = 1 ;
}
else
{
num = mtrx[no - n] + mtrx[no - n - 1] ;
}
mtrx[no] = num ;
}
}
}
printf (" the yang hui's delta is :");
for ( i = 0 ; i < n ; i ++)
{
printf ("\n");
no = i + n ;
for (i = 0 ; j <= i ; j ++)
{
printf(" %5d" , mtrx[no] );
no ++ ;
}
}
free (mtrx) ;
return 0 ;
}