![]() |
|
|
Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
Опции темы | Поиск в этой теме | Опции просмотра |
|
#1
|
|||
|
|||
![]() ![]() По заданию сделал 3 пункта, на 4ом больше часа тыркался, не получается. Код:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Math, ExtCtrls; type TForm1 = class(TForm) Edit1: TEdit; Button1: TButton; Memo1: TMemo; Label1: TLabel; Button2: TButton; Edit3: TEdit; Memo2: TMemo; Button3: TButton; Label3: TLabel; Edit2: TEdit; Button4: TButton; Label5: TLabel; GroupBox1: TGroupBox; GroupBox2: TGroupBox; Image1: TImage; Image2: TImage; Label2: TLabel; Label4: TLabel; Label6: TLabel; Label7: TLabel; GroupBox3: TGroupBox; GroupBox4: TGroupBox; Image3: TImage; Label8: TLabel; Button5: TButton; Button6: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure Button6Click(Sender: TObject); // procedure Button3Click(Sender: TObject); // procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var a:array[1..1000,1..1000] of real; x:array[1..1000] of real; n,m,i,j:integer; Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); //ïîñòðîèòü ìàòðèöó begin memo1.clear; n:=strtoint(edit1.Text); for i:=1 to n do begin memo1.lines.add(' '); for j:=1 to n do begin a[i,j]:=(sqr(2*i+2*j))/(exp(1/3*ln(i+j+5))); memo1.text:=memo1.text+floattostrf(a[i,j],fffixed,8,3)+' '; end; end; end; procedure TForm1.Button2Click(Sender: TObject); var maxj:integer; maxv:real; begin for i:=1 to n do begin maxv:=sqrt(a[i,1]); for j:=1 to n do begin if sqrt(a[i,j]) > maxv then maxv:=sqrt(a[i,j]);end; x[i]:=maxv end; for i:=1 to n do edit3.text:=edit3.text+floattostrf(X[i],fffixed,8,3)+' '; end; procedure TForm1.Button3Click(Sender: TObject); //ñîðòèðîâêà ïî óáûâàíèþ var i,j,z,w :integer; t:real; begin memo2.Clear; for i:=1 to n do for j:=i to n do begin if A[i,i] < A[j,j] then begin t:=A[i,i]; A[i,i]:=A[j,j]; A[j,j]:=t; end; end; for i:=1 to n do begin memo2.lines.add(' '); for j:=1 to n do memo2.text:=memo2.text+floattostrf(a[i,j],fffixed,8,3)+' '; end; end; procedure TForm1.Button4Click(Sender: TObject); var y1,y2:real; begin y1:=x[i]; y2:=0; for i:=1 to n do begin y1:=x[1]*x[1+2]; for j:=1 to n do begin y2:=y2+y1; end; edit4.Text:=floattostr(y1); edit2.text:=floattostr(y2); end; END; procedure TForm1.Button5Click(Sender: TObject); begin form1.Close; end; procedure TForm1.Button6Click(Sender: TObject); begin edit1.Text:=inttostr(3); memo1.Clear; memo2.Clear; edit3.Clear; edit2.clear; end; end. |
#2
|
|||
|
|||
![]() Вот кусок с 4ым пунктом
Код:
procedure TForm1.Button4Click(Sender: TObject); var y1,y2:real; begin y1:=x[i]; y2:=0; for i:=1 to n do begin y1:=x[1]*x[1+2]; for j:=1 to n do begin y2:=y2+y1; end; edit4.Text:=floattostr(y1); edit2.text:=floattostr(y2); end; END; |
#3
|
|||
|
|||
![]() После создания вектора Х, элемент х[i] почему то оказываеться последним, как считать с 1го элемента?
|
#4
|
||||
|
||||
![]() Это как понять?
Код:
procedure TForm1.Button4Click(Sender: TObject); var y1,y2:real; begin y1:=x[i]; y2:=0; for i:=1 to n do begin y1:=x[1]*x[1+2]; for j:=1 to n do begin y2:=y2+y1; end; edit4.Text:=floattostr(y1); edit2.text:=floattostr(y2); end; END; Je venus de nulle part 55.026263 с.ш., 73.397636 в.д. |
#5
|
|||
|
|||
![]() Изначально было y1=1, потом менял, пробывал по другому несколько раз.
|
#6
|
|||
|
|||
![]() Цитата:
Код:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Memo1: TMemo; Button1: TButton; OpenDialog1: TOpenDialog; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); const //buffer, inache zavisaet BLenMax = 100000; //mnozhestvo russkih bukv D = ['À'..'Ï', 'Ð'..'ß', '¨']; var F : File; Buff : array of Char; AStat : array[Char] of Integer; Ch : Char; i, BLenRes : Integer; razi : string; begin if OpenDialog1.InitialDir = '' then OpenDialog1.InitialDir := ExtractFilePath( Application.ExeName ) ; if not OpenDialog1.Execute then Exit; if not FileExists(Opendialog1.FileName) then begin MessageDlg( 'ôàéë ñ òàêèì èìåíåì íå íàéäåí', mtWarning, [mbOk], 0 ); Exit; end; //obnilyaem massiv for Ch := #0 to #255 do AStat[Ch] := 0; SetLength(Buff, BLenMax); //Open and read selected file AssignFile(F, OpenDialog1.FileName); Reset(F, 1); while not Eof(F) do begin BlockRead(F, Pointer(Buff)^, BLenMax, BLenRes); for i := 0 to BLenRes - 1 do begin Ch := AnsiUpperCase(Buff[i])[1]; Inc(AStat[Ch]); end; end; CloseFile(F); //vivod v memo1 Memo1.Lines.Add('Èñïîëüçîâà 37;û áóêâû:'); for Ch := #0 to #255 do begin if not (Ch in D) then Continue; Memo1.Lines.Add('Буква: "' + Ch + '", использована = ' + IntToStr(AStat[Ch])); end; end; end. |
#7
|
||||
|
||||
![]() Цитата:
Je venus de nulle part 55.026263 с.ш., 73.397636 в.д. |