Форум программистов, компьютерный форум, киберфорум
C++/CLI Windows Forms
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.91/11: Рейтинг темы: голосов - 11, средняя оценка - 4.91
0 / 0 / 0
Регистрация: 24.12.2011
Сообщений: 16

Реализация телефонной книги

26.05.2012, 17:39. Показов 2011. Ответов 1
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Код не работает , не могли бы подсказать где ошибка??
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
#pragma once
 
 
namespace Vicprak3 {
 
    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
    int ch=0;
 
//---------------------------------------------------------------------------
struct DeqElem 
{
    int name;
    double number;
    DeqElem *prev;
    DeqElem *next;
} *head = NULL, *tail = NULL, *current = NULL;
//---------------------------------------------------------------------------
 
 
    /// <summary>
    /// Summary for Form1
    ///
    /// WARNING: If you change the name of this class, you will need to change the
    ///          'Resource File Name' property for the managed resource compiler tool
    ///          associated with all .resx files this class depends on.  Otherwise,
    ///          the designers will not be able to interact properly with localized
    ///          resources associated with this form.
    /// </summary>
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
        Form1(void)
        {
            InitializeComponent();
            //
            //TODO: Add the constructor code here
            //
        }
 
    protected:
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        ~Form1()
        {
            if (components)
            {
                delete components;
            }
        }
    private: System::Windows::Forms::Button^  button1;
    private: System::Windows::Forms::Button^  button2;
    private: System::Windows::Forms::TextBox^  textBox1;
    private: System::Windows::Forms::TextBox^  textBox2;
    private: System::Windows::Forms::ListBox^  listBox1;
    private: System::Windows::Forms::Button^  button3;
    private: System::Windows::Forms::Button^  button4;
    private: System::Windows::Forms::TextBox^  textBox3;
    private: System::Windows::Forms::TextBox^  textBox4;
    private: System::Windows::Forms::Button^  button5;
    private: System::Windows::Forms::Button^  button6;
    private: System::Windows::Forms::TextBox^  textBox5;
    private: System::Windows::Forms::Label^  label1;
    private: System::Windows::Forms::Label^  label2;
    private: System::Windows::Forms::Label^  label3;
    private: System::Windows::Forms::Label^  label4;
    private: System::Windows::Forms::Label^  label5;
 
 
 
    protected: 
 
    private:
        /// <summary>
        /// Required designer variable.
        /// </summary>
        System::ComponentModel::Container ^components;
 
#pragma region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        void InitializeComponent(void)
        {
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->button2 = (gcnew System::Windows::Forms::Button());
            this->textBox1 = (gcnew System::Windows::Forms::TextBox());
            this->textBox2 = (gcnew System::Windows::Forms::TextBox());
            this->listBox1 = (gcnew System::Windows::Forms::ListBox());
            this->button3 = (gcnew System::Windows::Forms::Button());
            this->button4 = (gcnew System::Windows::Forms::Button());
            this->textBox3 = (gcnew System::Windows::Forms::TextBox());
            this->textBox4 = (gcnew System::Windows::Forms::TextBox());
            this->button5 = (gcnew System::Windows::Forms::Button());
            this->button6 = (gcnew System::Windows::Forms::Button());
            this->textBox5 = (gcnew System::Windows::Forms::TextBox());
            this->label1 = (gcnew System::Windows::Forms::Label());
            this->label2 = (gcnew System::Windows::Forms::Label());
            this->label3 = (gcnew System::Windows::Forms::Label());
            this->label4 = (gcnew System::Windows::Forms::Label());
            this->label5 = (gcnew System::Windows::Forms::Label());
            this->SuspendLayout();
            // 
            // button1
            // 
            this->button1->Location = System::Drawing::Point(713, 299);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(75, 23);
            this->button1->TabIndex = 0;
            this->button1->Text = L"Exit";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
            // 
            // button2
            // 
            this->button2->Location = System::Drawing::Point(263, 9);
            this->button2->Name = L"button2";
            this->button2->Size = System::Drawing::Size(75, 68);
            this->button2->TabIndex = 1;
            this->button2->Text = L"Add";
            this->button2->UseVisualStyleBackColor = true;
            this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
            // 
            // textBox1
            // 
            this->textBox1->Location = System::Drawing::Point(89, 9);
            this->textBox1->Multiline = true;
            this->textBox1->Name = L"textBox1";
            this->textBox1->Size = System::Drawing::Size(168, 26);
            this->textBox1->TabIndex = 2;
            // 
            // textBox2
            // 
            this->textBox2->Location = System::Drawing::Point(89, 49);
            this->textBox2->Multiline = true;
            this->textBox2->Name = L"textBox2";
            this->textBox2->Size = System::Drawing::Size(168, 28);
            this->textBox2->TabIndex = 3;
            // 
            // listBox1
            // 
            this->listBox1->FormattingEnabled = true;
            this->listBox1->Location = System::Drawing::Point(377, 54);
            this->listBox1->Name = L"listBox1";
            this->listBox1->Size = System::Drawing::Size(272, 251);
            this->listBox1->TabIndex = 4;
            // 
            // button3
            // 
            this->button3->Location = System::Drawing::Point(263, 106);
            this->button3->Name = L"button3";
            this->button3->Size = System::Drawing::Size(75, 23);
            this->button3->TabIndex = 5;
            this->button3->Text = L"Delete";
            this->button3->UseVisualStyleBackColor = true;
            this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
            // 
            // button4
            // 
            this->button4->Location = System::Drawing::Point(89, 266);
            this->button4->Name = L"button4";
            this->button4->Size = System::Drawing::Size(75, 23);
            this->button4->TabIndex = 6;
            this->button4->Text = L"Find";
            this->button4->UseVisualStyleBackColor = true;
            this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);
            // 
            // textBox3
            // 
            this->textBox3->Location = System::Drawing::Point(215, 202);
            this->textBox3->Name = L"textBox3";
            this->textBox3->Size = System::Drawing::Size(123, 20);
            this->textBox3->TabIndex = 7;
            // 
            // textBox4
            // 
            this->textBox4->Location = System::Drawing::Point(215, 228);
            this->textBox4->Multiline = true;
            this->textBox4->Name = L"textBox4";
            this->textBox4->Size = System::Drawing::Size(123, 20);
            this->textBox4->TabIndex = 8;
            // 
            // button5
            // 
            this->button5->Location = System::Drawing::Point(263, 145);
            this->button5->Name = L"button5";
            this->button5->Size = System::Drawing::Size(75, 23);
            this->button5->TabIndex = 9;
            this->button5->Text = L"Sort";
            this->button5->UseVisualStyleBackColor = true;
            this->button5->Click += gcnew System::EventHandler(this, &Form1::button5_Click);
            // 
            // button6
            // 
            this->button6->Location = System::Drawing::Point(671, 15);
            this->button6->Name = L"button6";
            this->button6->Size = System::Drawing::Size(117, 23);
            this->button6->TabIndex = 10;
            this->button6->Text = L"Selected Element";
            this->button6->UseVisualStyleBackColor = true;
            this->button6->Click += gcnew System::EventHandler(this, &Form1::button6_Click);
            // 
            // textBox5
            // 
            this->textBox5->Location = System::Drawing::Point(671, 61);
            this->textBox5->Multiline = true;
            this->textBox5->Name = L"textBox5";
            this->textBox5->Size = System::Drawing::Size(117, 52);
            this->textBox5->TabIndex = 11;
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->Location = System::Drawing::Point(9, 9);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(71, 13);
            this->label1->TabIndex = 12;
            this->label1->Text = L"Enter \"name\"";
            // 
            // label2
            // 
            this->label2->AutoSize = true;
            this->label2->Location = System::Drawing::Point(9, 49);
            this->label2->Name = L"label2";
            this->label2->Size = System::Drawing::Size(80, 13);
            this->label2->TabIndex = 12;
            this->label2->Text = L"Enter \"number\"";
            // 
            // label3
            // 
            this->label3->AutoSize = true;
            this->label3->Location = System::Drawing::Point(2, 205);
            this->label3->Name = L"label3";
            this->label3->Size = System::Drawing::Size(211, 13);
            this->label3->TabIndex = 12;
            this->label3->Text = L"Enter number elements which nesesery find";
            // 
            // label4
            // 
            this->label4->AutoSize = true;
            this->label4->Location = System::Drawing::Point(2, 235);
            this->label4->Name = L"label4";
            this->label4->Size = System::Drawing::Size(37, 13);
            this->label4->TabIndex = 12;
            this->label4->Text = L"Result";
            // 
            // label5
            // 
            this->label5->AutoSize = true;
            this->label5->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(204)));
            this->label5->Location = System::Drawing::Point(495, 15);
            this->label5->Name = L"label5";
            this->label5->Size = System::Drawing::Size(37, 24);
            this->label5->TabIndex = 12;
            this->label5->Text = L"List";
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(812, 334);
            this->Controls->Add(this->label2);
            this->Controls->Add(this->label5);
            this->Controls->Add(this->label4);
            this->Controls->Add(this->label3);
            this->Controls->Add(this->label1);
            this->Controls->Add(this->textBox5);
            this->Controls->Add(this->button6);
            this->Controls->Add(this->button5);
            this->Controls->Add(this->textBox4);
            this->Controls->Add(this->textBox3);
            this->Controls->Add(this->button4);
            this->Controls->Add(this->button3);
            this->Controls->Add(this->listBox1);
            this->Controls->Add(this->textBox2);
            this->Controls->Add(this->textBox1);
            this->Controls->Add(this->button2);
            this->Controls->Add(this->button1);
            this->Name = L"Form1";
            this->Text = L"Form1";
            this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
            this->ResumeLayout(false);
            this->PerformLayout();
 
        }
#pragma endregion
    private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e)
             {
             }
 
 
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e)
             {
                 this->Close();
             }
 
 
 /************************************************************************************************************/
    private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) 
{
    DeqElem *new_elem = new DeqElem;
    if (new_elem == NULL)
    {
        MessageBox::Show("При выделении памяти произошла ошибка... Повторите попытку","Error",
            MessageBoxButtons::OK,MessageBoxIcon::Error);
    }
    else
    {
 
        if(this->textBox1->Text == "")
        {
          MessageBox::Show("Enter Name","Error",
          MessageBoxButtons::OK,MessageBoxIcon::Error);
          this->Close();
        }
        else  new_elem->name =Convert::ToInt32( this->textBox1->Text);
 
        if(this->textBox2->Text == "")
        {
          MessageBox::Show("Enter Number","Error",
          MessageBoxButtons::OK,MessageBoxIcon::Error);
          this->Close();
        }
        else new_elem->number = Convert::ToDouble(this->textBox2->Text);
 
        if(head == NULL){
            new_elem->next = NULL;
            new_elem->prev = NULL;
            head = new_elem;
            tail = new_elem;
            current = new_elem;
        }else if(current == tail){
            new_elem->next = NULL;
            current->next = new_elem;
            new_elem->prev = current;
            current = new_elem;
            tail = new_elem;
        }else{
            new_elem->next = current->next;
            current->next->prev = new_elem;
            current->next = new_elem;
            new_elem->prev = current;
            current = new_elem;
        }
    }
        this->textBox1->Text = "";
        this->textBox2->Text = "";
 
        listBox1->Items->Add( "Текущая запись:     " + current->name + "  -  " + current->number);
        ch++;
}
 /************************************************************************************************************/
    private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) 
             {
    //String ^tmp = listBox1->Items[ch-1]->ToString();
    
    DeqElem *old_elem = current;
    if((old_elem != NULL) && (head == tail)){
        delete old_elem;
        tail = NULL;
        head = NULL;
        current = NULL;
    }
    if ((old_elem != NULL) && (head != tail)){
        if((old_elem != head) && (old_elem != tail)){
            current -> prev -> next = current -> next;
            current -> next -> prev = current -> prev;
            current = current -> prev;
            delete old_elem;
            listBox1->Items->RemoveAt(listBox1->Items->Count-1);
            //ch--;
        }else if(old_elem == tail){
            current = old_elem -> prev;
            current -> next = NULL;
            tail = current;
            delete old_elem;
            listBox1->Items->Clear();
            
            //ch--;
        }else if(old_elem == head){
            current = old_elem -> next;
            current -> prev = NULL;
            head = current;
            delete old_elem;
            listBox1->Items->RemoveAt(listBox1->Items->Count-1);
            //ch--;
            
        }
        
    }
    if(old_elem == NULL)
    {
        MessageBox::Show("ERROR! Elements are absent!","Error",
            MessageBoxButtons::OK,MessageBoxIcon::Error);
        
    }
 
    
 
             }
 /************************************************************************************************************/
 
    
 
private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e)
         {
             current = head;
             double find_number = 0;
            
             find_number = Convert::ToDouble(this->textBox3->Text);
            while(current != NULL)
            {
            if(current -> number == find_number)
            {
            this->textBox4->Text = "NAME: " + current -> name +"   "+ "NUMBER: " + current -> number;
            break;
            }
            current = current -> next;
            }
            if (this->textBox4->Text == "")this->textBox4->Text = "По вашему запросу ничего не найдено...";
         }
/************************************************************************************************************/
private: System::Void button5_Click(System::Object^  sender, System::EventArgs^  e) 
         {
             DeqElem *start = head;
        while(start != NULL){
        current = start;
        DeqElem *max_elem = start;
        while(current != NULL){
            if(max_elem -> number < current -> number)
                max_elem = current;
            current = current -> next;
        }
        current = start;
 
        int buf_name;
        int buf_number;
        buf_name = current -> name;
        buf_number = current -> number;
        current -> name = max_elem -> name;
        current -> number = max_elem -> number;
        max_elem -> name = buf_name;
        max_elem -> number = buf_number;
 
        start = start -> next;
    }
        /*******************************************/
    current = head;
    listBox1->Items->Clear();
    while(current != NULL){
        listBox1->Items->Add( "NAME: " + current -> name +"   "+ "NUMBER: " + current -> number );
        current = current -> next;
    }
    
    current = tail;
        /*******************************************/
 
         }
/************************************************************************************************************/
private: System::Void button6_Click(System::Object^  sender, System::EventArgs^  e) 
        {
            if(this->listBox1->SelectedIndex > 0)
            {
                String ^It = this->listBox1->Items[this->listBox1->SelectedIndex]->ToString();
                this->textBox5->Text = It;
            }
            else MessageBox::Show("Ничего не выделено\элемент был удален!","Error",MessageBoxButtons::OK,MessageBoxIcon::Error);
        }
/************************************************************************************************************/
};
}
0
IT_Exp
Эксперт
34794 / 4073 / 2104
Регистрация: 17.06.2006
Сообщений: 32,602
Блог
26.05.2012, 17:39
Ответы с готовыми решениями:

Получить контакт из телефонной книги
Домашнее задание. Помогите решить, уже 3 сутки не могу понять putExtra и getExtra. Условие: Получить контакт из телефонной книги в...

Сервис для телефонной книги
Доброго времени суток! Подскажите пожалуйста, как в Android можно поднять свой сервис для синхронизации туда контактов в телефонную...

Ошибочка в коде телефонной книги
Добрый день. Задача - написать телефонную книгу. Все работает, но... когда сначала добавляю контакт, потом удаляю и вывожу список......

1
162 / 162 / 42
Регистрация: 29.05.2010
Сообщений: 435
30.05.2012, 15:24
Где текст ошибки?
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
BasicMan
Эксперт
29316 / 5623 / 2384
Регистрация: 17.02.2009
Сообщений: 30,364
Блог
30.05.2012, 15:24
Помогаю со студенческими работами здесь

Скрипт на perl для телефонной книги
добрый день. нужна помощь знающих людей. есть база данных телефонов и сотрудников предприятия. база даннных postgresSQL. написал форму для...

Как сделать класс телефонной книги?
Здравствуйте, несколько дней назад начал изучать питон и столкнулся с сложностью в создании классов. Есть программа телефонная книга...

Отправить смс на номер из телефонной книги
Можете помочь в этом вопросе: &quot;Как отправить смс на номер из телефонной книги&quot; ? Как бы сначало нужно получить список всех контактов и...

Глючит получение id группы по id контакта телефонной книги
Все перерыл, не могу решить проблему Перепробовал разные методы получения айдишника группы, в которой находится контакт, по айдишнику...

Задача: написать программу электронной телефонной книги
Ребят выручайте плиз :) Очень Очень нужна эта задачка. Задача: написать программу электронной телефонной книги. Спецификация : -...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
2
Ответ Создать тему
Новые блоги и статьи
SDL3 для Web (WebAssembly): Обработчик клика мыши в браузере ПК и касания экрана в браузере на мобильном устройстве
8Observer8 02.02.2026
Содержание блога Для начала пошагово создадим рабочий пример для подготовки к экспериментам в браузере ПК и в браузере мобильного устройства. Потом напишем обработчик клика мыши и обработчик. . .
Философия технологии
iceja 01.02.2026
На мой взгляд у человека в технических проектах остается роль генерального директора. Все остальное нейронки делают уже лучше человека. Они не могут нести предпринимательские риски, не могут. . .
SDL3 для Web (WebAssembly): Вывод текста со шрифтом TTF с помощью SDL3_ttf
8Observer8 01.02.2026
Содержание блога В этой пошаговой инструкции создадим с нуля веб-приложение, которое выводит текст в окне браузера. Запустим на Android на локальном сервере. Загрузим Release на бесплатный. . .
SDL3 для Web (WebAssembly): Сборка C/C++ проекта из консоли
8Observer8 30.01.2026
Содержание блога Если вы откроете примеры для начинающих на официальном репозитории SDL3 в папке: examples, то вы увидите, что все примеры используют следующие четыре обязательные функции, а. . .
SDL3 для Web (WebAssembly): Установка Emscripten SDK (emsdk) и CMake для сборки C и C++ приложений в Wasm
8Observer8 30.01.2026
Содержание блога Для того чтобы скачать Emscripten SDK (emsdk) необходимо сначало скачать и уставить Git: Install for Windows. Следуйте стандартной процедуре установки Git через установщик. . . .
SDL3 для Android: Подключение Box2D v3, физика и отрисовка коллайдеров
8Observer8 29.01.2026
Содержание блога Box2D - это библиотека для 2D физики для анимаций и игр. С её помощью можно определять были ли коллизии между конкретными объектами. Версия v3 была полностью переписана на Си, в. . .
Инструменты COM: Сохранение данный из VARIANT в файл и загрузка из файла в VARIANT
bedvit 28.01.2026
Сохранение базовых типов COM и массивов (одномерных или двухмерных) любой вложенности (деревья) в файл, с возможностью выбора алгоритмов сжатия и шифрования. Часть библиотеки BedvitCOM Использованы. . .
SDL3 для Android: Загрузка PNG с альфа-каналом с помощью SDL_LoadPNG (без SDL3_image)
8Observer8 28.01.2026
Содержание блога SDL3 имеет собственные средства для загрузки и отображения PNG-файлов с альфа-каналом и базовой работы с ними. В этой инструкции используется функция SDL_LoadPNG(), которая. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru