,  , C++ Builder

 
 
KyoN
0 / 0 / 1
: 06.02.2013
: 64
#1

- C++ Builder

01.12.2014, 16:46. 596. 11
( )



http://www.cyberforum.ru/cpp-builder/thread2250649.html
0
 : zip LR1.zip (20.3 , 6 )
? .
Similar
41792 / 34177 / 6122
: 12.04.2006
: 57,940
01.12.2014, 16:46
(C++ Builder):


int pos; SaveDialog1->Execute(); if (SaveDialog1->FileName == "") {...


#include <vcl.h> #pragma hdrstop #include "Unit1.h"...


#include <windows.h> #include <mmsystem.h> #include <vcl.h> #pragma...

....
.... void __fastcall...

!
R1 R2. ,...

11
KyoN
0 / 0 / 1
: 06.02.2013
: 64
03.12.2014, 13:03  [] #2
:
[C++ Error] Unit1.h(46): E2303 Type name expected
[C++ Error] Unit1.h(46): E2139 Declaration missing ;
[C++ Error] Unit1.h(47): E2303 Type name expected
[C++ Error] Unit1.h(47): E2139 Declaration missing ;
[C++ Error] Unit1.cpp(17): E2089 Identifier 'ShowTreeInfo' cannot have a type qualifier
[C++ Error] Unit1.cpp(210): E2139 Declaration missing ;
[C++ Error] Unit1.cpp(210): E2134 Compound statement missing }

Unit1.h:
C++
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
57
//---------------------------------------------------------------------------
 
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ComCtrls.hpp>
#include <Dialogs.hpp>
 
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:    // IDE-managed Components
        TGroupBox *boxActon;
        TGroupBox *boxTreeView;
        TGroupBox *boxListView;
        TListBox *listBox;
        TTreeView *treeView;
        TLabel *Label1;
        TLabel *Label2;
        TLabel *Label3;
        TLabel *Label4;
        TLabel *labelCountNode;
        TLabel *labelCountLeaf;
        TLabel *labelDepth;
        TLabel *labelTreeSearch;
        TLabel *labelListSearch;
        TEdit *editShet;
        TEdit *editAbonent;
        TEdit *editTelefon;
        TEdit *editDom;
        TButton *btnInsert;
        TButton *btnClear;
        TButton *btnLoad;
        TButton *btnSearch;
        TOpenDialog *OpenDialog1;
        void __fastcall btnInsertClick(TObject *Sender);
        void __fastcall btnClearClick(TObject *Sender);
        void __fastcall btnLoadClick(TObject *Sender);
        void __fastcall btnSearchClick(TObject *Sender);
private:    // User declarations
        CBinTree<data> tree;         // îáúÿâëå*èå áè**ð*îãî äåðåâ*
        CMyList<data> list;          // è ñâÿç***îãî ñïèñê*
        void ShowTreeInfo();         // âûâîäèò è*ôîðì*öèþ ïî äåðåâó
        unsigned __int64 RDTSC();    // îïðåäåëÿåò ñêîëüêî ò*êòîâ ñäåë*ë
                                     // CPU ïîñëå âêëþ÷å*èÿ êîìïüþòåð*
        unsigned int CpuFrequency(); // âû÷èñëÿåò ÷*ñòîòó CPU â ãåðö*õ
public:     // User declarations
        __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
Unit1.cpp
C++
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
//---------------------------------------------------------------------------
 
#include <vcl.h>
#pragma hdrstop
 
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
using namespace std;
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
void TForm1::ShowTreeInfo()
{
  labelCountNode->Caption = "Óçëîâ: " + IntToStr(tree.CountNode());
  labelCountLeaf->Caption = "Ëèñòüåâ: " + IntToStr(tree.CountLeaf());
  labelDepth->Caption = "Ãëóáè**: " + IntToStr(tree.GetDepth());
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnInsertClick(TObject *Sender)
{
// Åñëè ç*ïîë*å*û *å âñå è*ôîðì*öèî**ûå ïîëÿ - òî âûõîäèì ñ ñîîáùå*èåì.
  if ((editAbonent->Text=="")||(editTelefon->Text=="")||(editDom->Text=="")||(editShet->Text=="")){
      MessageDlg("Äëÿ âñò*âêè *îâîãî óçë* òðåáóåòñÿ ç*ïîë*èòü âñå è*ôîðì*öèî**ûå ïîëÿ.", mtInformation, TMsgDlgButtons() << mbOK, 0);
      return;
  }
 
  // ç*ïîë*ÿåì ïîëÿ ñòðóêòóð d1 è d2
  data d1,d2;
  d1.SHET = atof(editShet->Text.c_str());
  strcpy(d1.TELEFON, editTelefon->Text.c_str());
  strcpy(d1.N_DOMA, editDom->Text.c_str());
  strcpy(d1.ABONENT, editAbonent->Text.c_str());
 
  d2 = d1;
 
  // è äîá*âëÿåì èõ â äåðåâî
  if (tree.Insert(d1))
  {
    ShowTreeInfo();
    // îòîáð*æ*åì äåðåâî
    treeView->Items->Clear();
    Inorder(tree.GetRoot(), NULL);
    treeView->FullExpand();
    // è ñïèñîê
    list.Insert(d2);
    listBox->Items->Add(FloatToStr(d2.SHET));
  }
  else
  {
      MessageDlg(" äåðåâå óæå åñòü óçåë ñ óê*ç***ûì êëþ÷åì.", mtInformation, TMsgDlgButtons() << mbOK, 0);
      return;
  }
}
//---------------------------------------------------------------------------
template <class T>
void Inorder(CTreeNode<T> *t, TTreeNode *node)
{
  // Ðåêóðñèâ*îå ïðîõîæäå*èå ç*ê**÷èâ*åòñÿ ** ïóñòîì ïîääåðåâå
  if (t != NULL)
  {
    // îòîáð*çèòü òåêóùèé óçåë
    AnsiString s=FloatToStr(t->data.SHET); // ä***ûå èç òåêóùåãî óçë*
 
    // äîá*âëÿåì â äåðåâî âåðøè*ó
    node = Form1->treeView->Items->AddChild(node, s);
 
    // ñåé÷*ñ node ñîäåðæèò óê*ç*òåëü ** äîá*âëå**óþ âåðøè*ó
    // ñïóñòèòüñÿ ïî ëåâîìó ïîääåðåâó
    Inorder(t->GetLeftPtr(), node);
 
    // ñïóñòèòüñÿ ïî ïð*âîìó ïîääåðåâó
    Inorder(t->GetRightPtr(), node);
  }
}
void __fastcall TForm1::btnClearClick(TObject *Sender)
{
// óä*ëÿåì âñå ýëåìå*òû èç äåðåâ* è ñïèñê*
  tree.DeleteTree(tree.GetRoot());
  list.DeleteAllElem();
  treeView->Items->Clear();
  listBox->Clear();
  ShowTreeInfo();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnLoadClick(TObject *Sender)
{
if (OpenDialog1->Execute())
  {
    // óä*ëÿåì âñå ýëåìå*òû èç äåðåâ* è ñïèñê*
    tree.DeleteTree(tree.GetRoot());
    list.DeleteAllElem();
    treeView->Items->Clear();
    listBox->Clear();
 
    // îòêðûâ*åì ô*éë ñ ä***ûìè
    ifstream f(OpenDialog1->FileName.c_str());
 
    char buffer[80]; // ñþä* ñ÷èòûâ*åòñÿ ñòðîê*
    TStringList *subStrings = new(TStringList); // äëÿ ïîäñòðîê èç áóôåð*
 
    f.getline(buffer, 80);  // ïðîïóñê*åì ø*ïêó ò*áëèöû
    while (true)
    {
      f.getline(buffer, 80); // ÷èò*åì î÷åðåä*óþ ñòðîêó
      if (f.eof())  break; // åñëè êî*åö ô*éë* - âûõîäèì èç öèêë*
 
      // âûäåëÿåì ïîäñòðîêè
      ExtractStrings(TSysCharSet()<<'\t', TSysCharSet()<<' ', buffer, subStrings);
 
      // ç*ïîë*ÿåì è*ôîðì*öèî**ûå ñòðóêòóðû
      data d1,d2;
      d1.SHET = StrToFloat(subStrings->Strings[0].c_str());
      strcpy(d1.TELEFON, subStrings->Strings[1].c_str());
      strcpy(d1.N_DOMA, subStrings->Strings[2].c_str());
      strcpy(d1.ABONENT, StrToFloat(subStrings->Strings[3].c_str()))
      d2 = d1;
 
      // äîá*âëÿåì â äåðåâî
      if (tree.Insert(d1))
      { // è â ñïèñîê
        list.Insert(d2);
        listBox->Items->Add(FloatToStr(d2.SHET));
      }
      subStrings->Clear();
    }
    f.close();
    // Îòîáð*æ*åì ñò*òèñòèêó è ñ*ìî äåðåâî.
    ShowTreeInfo();
    Inorder(tree.GetRoot(), NULL);
    treeView->FullExpand();
  }
}
//---------------------------------------------------------------------------
// Âîçâð*ù*åò êîëè÷åñòâî ò*êòîâ ïðîöåññîð*.
unsigned __int64 TForm1::RDTSC()
{
  ULARGE_INTEGER TimeStamp;
  DWORD dwTimerHi, dwTimerLo;
  asm
  {
    DW 0x310F
    mov dwTimerLo, EAX
    mov dwTimerHi, EDX
  }
  TimeStamp.LowPart = dwTimerLo;
  TimeStamp.HighPart = dwTimerHi;
  return TimeStamp.QuadPart;
}
 
// Îïðåäåëÿåò ÷*ñòîòó ïðîöåññîð*.
unsigned int TForm1::CpuFrequency()
{
  unsigned __int64 t1, t2;
  Sleep(1);
  t1 = RDTSC();
  Sleep(1000);
  t2 = RDTSC();
  return t2-t1;
}
//-------------------------------------------------------------------------
void __fastcall TForm1::btnSearchClick(TObject *Sender)
{
// Âûõîäèì, åñëè *å ç*ä** êëþ÷ ïîèñê*
  if (editShet->Text == "")
  {
      MessageDlg("Íå ç*ä** êëþ÷", mtInformation, TMsgDlgButtons()<< mbOK, 0);
      return;
  }
 
  data d;
  d.SHET = StrToFloat(editShet->Text); // óñò***âëèâ*åì êëþ÷
  unsigned int Freq = CpuFrequency(); // âû÷èñëÿåì ÷*ñòîòó CPU
  unsigned __int64 t1,t2;
 
  t1 = RDTSC(); // **÷*ëî îòñ÷åò*
  CTreeNode<data>* node = tree.Find(d); // ïîèñê
  t2 = RDTSC(); // êî*åö îòñ÷åò*
 
  labelTreeSearch->Caption =
    "Ïîèñê â äåðåâå: " +
    FloatToStr(int(float(t2-t1) / float(Freq) * 1000000.0)) + " ìêñ.";
 
  t1 = RDTSC();
  list.Find(d);
  t2 = RDTSC();
 
  labelListSearch->Caption =
    "Ïîèñê â ñïèñêå: " +
    FloatToStr(int(float(t2-t1) / float(Freq) * 1000000.0)) + " ìêñ.";
 
  // Åñëè *è÷åãî *å **øëè - ñîîáù*åì
  if (node == NULL)
    MessageDlg("Óçåë ñ êëþ÷åì '" +editShet->Text+ "' îòñóòñòâóåò.", mtInformation,TMsgDlgButtons() << mbOK, 0);
  else // è**÷å - âûâîäèì **éäå**ûå ä***ûå
  {
    editShet->Text = FloatToStr(node->data.SHET);
    editTelefon->Text = node->data.TELEFON;
    editDom->Text = node->data.N_DOMA;
    editAbonent->Text = FloatToStr(node->data.ABONENT);
  }
}
};
0
gumi250
431 / 398 / 57
: 06.02.2012
: 1,373
03.12.2014, 13:10 #3
C++
1
2
CBinTree<data> tree;        
CMyList<data> list;
?
0
KyoN
0 / 0 / 1
: 06.02.2013
: 64
03.12.2014, 13:17  [] #4
. Data.h
, .
0
gumi250
431 / 398 / 57
: 06.02.2012
: 1,373
03.12.2014, 13:18 #5
KyoN
Data.h
?
0
KyoN
0 / 0 / 1
: 06.02.2013
: 64
03.12.2014, 13:28  [] #6
2 , 3 :
[C++ Error] Unit1.cpp(17): E2089 Identifier 'ShowTreeInfo' cannot have a type qualifier
[C++ Error] Unit1.cpp(210): E2139 Declaration missing ;
[C++ Error] Unit1.cpp(210): E2134 Compound statement missing }
0
gumi250
431 / 398 / 57
: 06.02.2012
: 1,373
03.12.2014, 13:34 #7
C++
1
2
3
4
5
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
void TForm1::ShowTreeInfo()
{
?
0
KyoN
0 / 0 / 1
: 06.02.2013
: 64
03.12.2014, 13:38  [] #8
. ?
0
gumi250
431 / 398 / 57
: 06.02.2012
: 1,373
03.12.2014, 13:39 #9
? . .
0
KyoN
0 / 0 / 1
: 06.02.2013
: 64
03.12.2014, 13:41  [] #10
?
0
gumi250
431 / 398 / 57
: 06.02.2012
: 1,373
03.12.2014, 13:41 #11
TForm1::TForm1. .
0
KyoN
0 / 0 / 1
: 06.02.2013
: 64
04.12.2014, 01:26  [] #12
:
C++
1
2
3
4
5
6
7
8
9
10
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
void TForm1::ShowTreeInfo()
{
  labelCountNode->Caption = "Óçëîâ: " + IntToStr(tree.CountNode());
  labelCountLeaf->Caption = "Ëèñòüåâ: " + IntToStr(tree.CountLeaf());
  labelDepth->Caption = "Ãëóáè**: " + IntToStr(tree.GetDepth());
}
:
[C++ Error] Unit1.cpp(18): E2451 Undefined symbol 'tree'
[C++ Error] Unit1.cpp(33): E2451 Undefined symbol 'data'
[C++ Error] Unit1.cpp(33): E2379 Statement missing ;
[C++ Error] Unit1.cpp(34): E2451 Undefined symbol 'd1'
[C++ Error] Unit1.cpp(39): E2451 Undefined symbol 'd2'
[C++ Error] Unit1.cpp(42): E2451 Undefined symbol 'tree'
[C++ Error] Unit1.cpp(47): E2268 Call to undefined function 'Inorder'
[C++ Error] Unit1.cpp(50): E2451 Undefined symbol 'list'
[C++ Error] Unit1.cpp(61): E2451 Undefined symbol 'CTreeNode'
(

11 30
0
04.12.2014, 01:26
MoreAnswers
37091 / 29110 / 5898
: 17.06.2006
: 43,301
04.12.2014, 01:26
! :


Unit3.cpp(28): E2451 Undefined symbol 'TreeNode' Full parser context ...


, ...

!
//--------------------------------------------------------------------------- ...


: ...




:
12

- , ,
-
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
@Mail.ru