![]() |
|
Модераторы: Poseidon |
![]()
|
|
| Bedboy |
|
|||
|
Новичок Профиль Группа: Участник Сообщений: 4 Регистрация: 27.3.2008 Репутация: нет Всего: нет |
в програму нужно добавить: запись слов с edita 1,3 у файл а потом при открытии заносились в ListBox1; правильно росшифровувать сообщение исли в ключевом словеесть два одинаковых символа ато она на етом морозится;и где возможно упростить код желательно с коиентами пожалуста
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit1.h" #include "math.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { AnsiString s = Edit3->Text; for (int i=1; i<=5; i++){ mf[i-1]=s[i]; StringGrid1->Cells [i][0]= s[i]; } } //--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) { AnsiString s = Edit1->Text; for (int i=1; i<=5; i++){ ms[i-1]=s[i]; StringGrid1->Cells [0][i]= s[i]; } } //--------------------------------------------------------------------------- void __fastcall TForm1::Button3Click(TObject *Sender) { AnsiString s = Edit2->Text; for (int i=1; i<=5; i++){ mas[i-1]=s[i]; mas[i+4]=s[i+5]; mas[i+9]=s[i+10]; mas[i+14]=s[i+15]; mas[i+19]=s[i+20]; StringGrid1->Cells [i][1]= s[i]; StringGrid1->Cells [i][2]= s[i+5]; StringGrid1->Cells [i][3]= s[i+10]; StringGrid1->Cells [i][4]= s[i+15]; StringGrid1->Cells [i][5]= s[i+20]; } } //--------------------------------------------------------------------------- void __fastcall TForm1::Button6Click(TObject *Sender) { int i,j; char buf,buf2,buf3,buf4, buf5,buf6; for (i=0; i< 5 - 1; i++){ for (j=i+1; j< 5; j++){ if (mf[j] < mf[i]){ buf = mf[j]; buf2 = mas[j]; buf3 = mas[j+5]; buf4 = mas[j+10]; buf5 = mas[j+15]; buf6 = mas[j+20]; mf[j]= mf[i]; mas[j] = mas[i]; mas[j+5] = mas[i+5]; mas[j+10] = mas[i+10]; mas[j+15] = mas[i+15]; mas[j+20] = mas[i+20]; mf[i]= buf; mas[i]= buf2; mas[i+5] =buf3; mas[i+10] =buf4; mas[i+15] =buf5; mas[i+20] =buf6; } } } for (int k=1; k<=5; k++){ StringGrid1->Cells [k][0]= mf[k-1]; } for (int p=1; p<=5; p++){ StringGrid1->Cells [p][1]= mas[p-1]; StringGrid1->Cells [p][2]= mas[p+4]; StringGrid1->Cells [p][3]= mas[p+9]; StringGrid1->Cells [p][4]= mas[p+14]; StringGrid1->Cells [p][5]= mas[p+19]; } } //--------------------------------------------------------------------------- void __fastcall TForm1::Button7Click(TObject *Sender) { int i,j,v,w; char buf,buf2,buf3,buf4, buf5,buf6; for (i=0; i< 5 - 1; i++){ for (j=i+1; j< 5; j++){ if (ms[j] < ms[i]){ buf = ms[j]; if (j==0){v=0;} if (j==1){v=5;} if (j==2){v=10;} if (j==3){v=15;} if (j==4){v=20;} buf2 = mas[v]; buf3 = mas[v+1]; buf4 = mas[v+2]; buf5 = mas[v+3]; buf6 = mas[v+4]; ms[j]= ms[i]; if (i==0){w=0;} if (i==1){w=5;} if (i==2){w=10;} if (i==3){w=15;} if (i==4){w=20;} mas[v] = mas[w]; mas[v+1] = mas[w+1]; mas[v+2] = mas[w+2]; mas[v+3] = mas[w+3]; mas[v+4] = mas[w+4]; ms[i]= buf; mas[w]= buf2; mas[w+1] =buf3; mas[w+2] =buf4; mas[w+3] =buf5; mas[w+4] =buf6; } } } for (int k=1; k<=5; k++){ StringGrid1->Cells [0][k]= ms[k-1]; } for (int p=1; p<=5; p++){ StringGrid1->Cells [p][1]= mas[p-1]; StringGrid1->Cells [p][2]= mas[p+4]; StringGrid1->Cells [p][3]= mas[p+9]; StringGrid1->Cells [p][4]= mas[p+14]; StringGrid1->Cells [p][5]= mas[p+19]; } } //4 по первому и 3 по второму слову. //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- void __fastcall TForm1::Button4Click(TObject *Sender) { Form1->ListBox1->AddItem(Edit3->Text, NULL); Form1->ListBox1->AddItem(Edit1->Text, NULL); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button8Click(TObject *Sender) { AnsiString s = Edit4->Text; for (int i=1; i<=5; i++){ mfh[i-1]=s[i]; } } //--------------------------------------------------------------------------- void __fastcall TForm1::ListBox1Click(TObject *Sender) { Edit4->Text = ListBox1->Items->Strings[ListBox1->ItemIndex] ; } //--------------------------------------------------------------------------- void __fastcall TForm1::Button9Click(TObject *Sender) { AnsiString s = Edit4->Text; for (int i=1; i<=5; i++){ msh[i-1]=s[i]; } } //--------------------------------------------------------------------------- void __fastcall TForm1::Button10Click(TObject *Sender) { char a; int v=0; int w=0; for (int i=0; i<5; i++){ for (int j=0; j<5; j++){ if ( msh[i]==ms[j]){ msh2[i]=ms[j]; if (j==0){v=0;} if (j==1){v=5;} if (j==2){v=10;} if (j==3){v=15;} if (j==4){v=20;} if (i==0){w=0;} if (i==1){w=5;} if (i==2){w=10;} if (i==3){w=15;} if (i==4){w=20;} mas2[w]=mas[v]; mas2[w+1]=mas[v+1]; mas2[w+2]=mas[v+2]; mas2[w+3]=mas[v+3]; mas2[w+4]=mas[v+4]; } } } for (int k=0; k<25; k++){ mas[k]=mas2[k]; } for (int i=0; i<5; i++){ for (int j=0; j<5; j++){ if ( mfh[i]==mf[j]){ mfh2[i]=mf[j]; mas2[i]=mas[j]; mas2[i+5]=mas[j+5]; mas2[i+10]=mas[j+10]; mas2[i+15]=mas[j+15]; mas2[i+20]=mas[j+20]; } } } for (int p=1; p<=5; p++){ StringGrid1->Cells [p][1]= mas2[p-1]; StringGrid1->Cells [p][2]= mas2[p+5-1]; StringGrid1->Cells [p][3]= mas2[p+10-1]; StringGrid1->Cells [p][4]= mas2[p+15-1]; StringGrid1->Cells [p][5]= mas2[p+20-1]; } } //--------------------------------------------------------------------------- void __fastcall TForm1::Button11Click(TObject *Sender) { for (int p=0; p<25; p++){ StringGrid3->Cells [p][0]= mas2[p]; } } //--------------------------------------------------------------------------- void __fastcall TForm1::Button13Click(TObject *Sender) { Close(); } //--------------------------------------------------------------------------- void __fastcall TForm1::Exit1Click(TObject *Sender) { for (int i=0; i<5; i++){ mf[i]=0; ms[i]=0; mfh[i]=0; mfh2[i]=0; msh[i]=0; msh2[i]=0; } for (int i=0; i<25; i++){ mas[i]=0; mas2[i]=0; StringGrid3->Cells [i][0]= ' '; } for (int i=0; i<6; i++){ StringGrid1->Cells [i][0]= ' '; StringGrid1->Cells [i][1]= ' '; StringGrid1->Cells [i][2]= ' '; StringGrid1->Cells [i][3]= ' '; StringGrid1->Cells [i][4]= ' '; StringGrid1->Cells [i][5]= ' '; } Edit1->Text = ' '; Edit2->Text = ' '; Edit3->Text = ' '; Edit4->Text = ' '; } //--------------------------------------------------------------------------- void __fastcall TForm1::Exit2Click(TObject *Sender) { Close(); } //--------------------------------------------------------------------------- |
|||
|
||||
![]()
|
| Правила форума "Центр помощи" | |
|
|
ВНИМАНИЕ! Прежде чем создавать темы, или писать сообщения в данный раздел, ознакомьтесь, пожалуйста, с Правилами форума и конкретно этого раздела.
Более подробно с правилами данного раздела Вы можете ознакомится в этой теме. Если Вам помогли и атмосфера форума Вам понравилась, то заходите к нам чаще! С уважением, Poseidon, Rodman |
| 0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей) | |
| 0 Пользователей: | |
| « Предыдущая тема | Центр помощи | Следующая тема » |
|
|
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности Powered by Invision Power Board(R) 1.3 © 2003 IPS, Inc. |