struct Polinom int coef int int int Polinom next void __fastcall TForm

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
struct Polinom
{
int coef;
int x;
int y;
int z;
Polinom* next;
};
void __fastcall TForm2::BitBtn1Click(TObject *Sender)
{
String str;
Polinom *pointer, head;
pointer=&head;
str= Edit1->Text;
for (int i=0;i<str.Length();i++)
{
int in=0;
int coef=0;
int x=0,y=0,z=0;
if (isdigit(str[i]) && in==0)
{
coef = str[i]-48;
in = 1;
pointer->next= new Polinom;
pointer=pointer->next;
pointer->coef=coef;
}
if (isdigit(str[i]) && in==1)
{
if (str[i-2]=='x')
{
x=str[i]-48;
pointer->x=x;
}
else
if (str[i-2]=='y')
{
y=str[i]-48;
pointer->y=y;
}
else
if (str[i-2]=='z')
{
z=str[i]-48;
pointer->z=z;
pointer->next=NULL;
}
}
if ((str[i]=='+') || (str[i]=='-'))
{
in=0;coef=0;x=0;y=0;z=0;
//ShowMessage(IntToStr(pointer->coef));
}
}