![]() |
|
|
Регистрация Восстановить пароль |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
![]() |
|
Опции темы | Поиск в этой теме |
![]() |
#1 |
Пользователь
Регистрация: 26.03.2011
Сообщений: 18
|
![]()
Вот текст программы:
#include <vcl.h> #include <fstream.h> #pragma hdrstop #include "Stack1.h" #include "lr6.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- CStack S1; __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) { AnsiString prov = ""; int a = ListBox2->Items->Count; int bip = StrToInt(Edit3->Text); if (Edit4->Text == "" || Edit5->Text == "" || Edit6->Text == "" /*|| bip<0 || bip>9999*/) { ListBox1->Items->Add("Неверный ввод"); } else { if (a!=6) { S1.add(Edit1->Text); ListBox2->Items->Add(Edit1->Text); ListBox3->Items->Add(Edit3->Text); ListBox5->Items->Add(Edit5->Text); ListBox6->Items->Add(Edit6->Text); ListBox4->Items->Add(Edit4->Text); for (int pr=a; pr!=1; pr--) { ListBox2->Items->Exchange(pr-1,pr); ListBox3->Items->Exchange(pr-1,pr); ListBox4->Items->Exchange(pr-1,pr); ListBox6->Items->Exchange(pr-1,pr); ListBox5->Items->Exchange(pr-1,pr); } if (Edit1->Text != "") ListBox1->Items->Add("Клиент добавлен"); Edit1->Text = ""; Edit3->Text = ""; Edit4->Text = ""; Edit5->Text = ""; Edit6->Text = ""; } else { ListBox1->Items->Add("СТЕК переполнен. Предмет не добавлен в СТЕК"); } } } //--------------------------------------------------------------------------- void __fastcall TForm1::Button3Click(TObject *Sender) { int a = ListBox2->Items->Count; if (a > 1) { ListBox2->Items->Delete(1); ListBox3->Items->Delete(1); ListBox4->Items->Delete(1); ListBox5->Items->Delete(1); ListBox6->Items->Delete(1); ListBox1->Items->Add("Элемент удален из СТЕКА"); S1.del(); } else { ListBox1->Items->Add("СТЕК пуст"); } } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { int a = ListBox3->Items->Count; for (int h=1; h<5; h++) { for (int i=2; i<a; i++) { if (ListBox3->Items->Strings[i] < ListBox3->Items->Strings[i-1]) { ListBox4->Items->Exchange(i-1,i); ListBox2->Items->Exchange(i-1,i); ListBox3->Items->Exchange(i-1,i); ListBox5->Items->Exchange(i-1,i); ListBox6->Items->Exchange(i-1,i); } } } ListBox1->Items->Add("Сортировка по номеру счёта завершена"); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button4Click(TObject *Sender) { int pr=0; char ch; AnsiString ans; ifstream fi("lr6.txt"); while (!fi.eof()) { fi>>ch; if (ch!=',') { ans += ch; } else { pr++; if (pr==1){ ListBox3->Items->Add(ans); ans="";} if (pr==2){ ListBox2->Items->Add(ans); ans="";} if (pr==3){ ListBox4->Items->Add(ans); ans="";} if (pr==4){ ListBox5->Items->Add(ans); ans="";} if (pr==5) { ListBox6->Items->Add(ans); pr=0; ans=""; int a = ListBox2->Items->Count; for (int prov=a-1; prov!=1; prov--) { ListBox2->Items->Exchange(prov-1,prov); ListBox4->Items->Exchange(prov-1,prov); ListBox6->Items->Exchange(prov-1,prov); ListBox5->Items->Exchange(prov-1,prov); } } } } int w = ListBox3->Items->Count; ListBox3->Items->Delete(w-1); ListBox1->Items->Add("СТЕК заполнен из файла"); fi.close(); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button5Click(TObject *Sender) { ofstream fi("lr6.txt", ios::app); int n = ListBox2->Items->Count; for (int i=1; i<n; i++) { AnsiString m; m = ListBox3->Items->Strings[i]; fi<<m.c_str()<<", "; m = ListBox2->Items->Strings[i]; fi<<m.c_str()<<", "; m = ListBox4->Items->Strings[i]; fi<<m.c_str()<<", "; m = ListBox5->Items->Strings[i]; fi<<m.c_str()<<", "; m = ListBox6->Items->Strings[i]; fi<<m.c_str()<<", "; } fi.close(); } |
![]() |
![]() |
![]() |
![]() |
||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
Где в программе перегрузка операторов? | Kroleg | Помощь студентам | 5 | 27.12.2011 02:13 |
Не запускается программа на перегрузку операций(*+). Найти ошибку в программе | Alex++ | Помощь студентам | 0 | 16.12.2011 10:33 |
Программа на языке С с использованием условных операторов и операторов цикла. | Valentin Pirgach | Помощь студентам | 0 | 17.10.2011 20:16 |
Как добавить иконку к простой программе? | AstraZak | Общие вопросы C/C++ | 2 | 28.11.2009 13:42 |
Оптимизировать перегрузку операторов | Иллидан | Общие вопросы C/C++ | 14 | 24.04.2008 11:18 |