我应该制作 2 个构建图形的代码。我已经有 1。它只是在构建图片:
double a = LabeledEdit1 -> Text.ToDouble();
double S = LabeledEdit2 -> Text.ToDouble();
Series1-> Clear();
for( float i = -5; i <= 5; i+=S ) {
float y = exp(i*log(a));
Series1->AddXY( i , y ,"",clBlue);
}
但是第二个任务对我来说要困难得多。我应该做新的结构
struct K {
double x;
double y;
struct K *next;
};
然后制作链表。然后将点 (x,y) 放到 StringGrid 中,然后构建图形。我做了一些代码,但它不能正常工作。需要帮忙。
K* head = 0;
K* curr = 0;
K* vyv;
double x = 1;
double y;
double a = LabeledEdit1 -> Text.ToDouble();
double S = LabeledEdit2 -> Text.ToDouble();
int i=0;
for (i = 0; i < 500; ++i) {
if (i==0) {
y = exp(x*log(a));
head = (K*) malloc(sizeof K);
head->x = x;
head->y = y;
head->next = NULL;
}
else {
y = exp(x*log(a));
curr = (K*) malloc(sizeof K);
curr->x = x;
curr->y = y;
curr->next = NULL;
}
x++;
}
vyv = head;
i = 0;
int l = 0, I = 0;
while(vyv){
x = vyv->x;
StringGrid1->Cells[i][0] = x;
y = vyv->y;
StringGrid1->Cells[i][1] = y;
Series1->AddXY( i , y ,"",clBlue);
vyv = vyv->next;
++i;
}