请问为什么这个程序实现不了,悬赏100分
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#pragma hdrstop
#pragma argsused
typedef struct node {
float value;
struct node *up;
struct node *down;
}Node,*PNode;
int getPos(int count)
{
int num = 0;
int i ;
//计算用多少个 容器
for (i = 0 ; i < count; i ++)
{
num += i+1;
}
return num;
}
void lattice( float x1 , float x2 ,int count)
{
Node *all;
int i ;
int j ;
int num = 0;
int pos = 0;
num = getPos(count+1);
//printf("num=%d\n",num);
all = (Node*)malloc(sizeof(Node)* num);
// ---
for (i = 0 ; i <= count ; i ++)
{
for (j = 0 ; j <= i ; j ++)
{
all[pos].value = pos;
printf("i=%d,j=%d,v=%f\n",i,j,all[pos].value);
pos++;
}
}
all[0].value = x1;
pos = 0;
for (i = 1 ; i <= count ; i ++)
{
j = 0;
while ( j < i )
{
printf("-%d %d\n" , getPos(i-1)+j , getPos(i) + j);
printf("--%d %d\n" , getPos(i-1)+j , getPos(i) + j+1);
all[getPos(i-1)+j].up = &all[getPos(i)+j];
all[getPos(i-1)+j].down = &all[getPos(i)+j+1];
all[getPos(i)+j].value = all[getPos(i-1)+j].value * x2;
all[getPos(i)+j+1].value = all[getPos(i-1)+j].value / x2;
j ++;
}
}
// 遍历
{
FILE *stream;
/* open a file for update */
stream = fopen("lattice.csv", "w+");
pos = 0;
for (i = 0 ; i <= count ; i ++)
{
for (j = 0 ; j <= i ; j ++)
{
fprintf(stream, "%d,%d,%f\n",i,j,all[pos].value);
printf("%d,%d,%f\n",i,j,all[pos].value);
pos++;
}
}
/* close the file */
fclose(stream);
}
}
int main(int argc, char* argv[])
{
//printf("start ");
float x1;
float x2;
int x3;
if (argc <= 3)
{
printf("lattice.exe 81 1.5 4\n");
return 0;
}
x1 = atol(argv[1]);
x2 = atof(argv[2]);
x3 = atoi(argv[3]);
lattice(x1,x2,x3);
return 0;
}