Программирование на языках высокого уровня

Автор работы: Пользователь скрыл имя, 18 Ноября 2009 в 19:23, Не определен

Описание работы

Курсовая работа по программе Паскаль

Файлы: 3 файла

0640_05.doc

— 70.00 Кб (Скачать файл)

 задача №2

unit Unit1;

interface

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls;

type

  TForm1 = class(TForm)

    Edit1: TEdit;

    Button1: TButton;

    memo: TMemo;

    Label1: TLabel;

    procedure Button1Click(Sender: TObject);

    procedure FormCreate(Sender: TObject);

   private

    { Private declarations }

  public

    { Public declarations }

  end;

var

  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

var i,j,b,k:integer;

    a:array [1..3267] of integer;

begin

a[1]:=2;

j:=1;

for i:=3 to strtoint(edit1.text) do begin

 b:=1;

for k:=1 to j do if ((i mod a[k])=0) then b:=0;

if b=1 then

  begin

   j:=j+1;

   a[j]:=i;

  end;

end;

if edit1.Text=inttostr(1) then memo.Text:=inttostr(1);

if edit1.Text=inttostr(2) then memo.Text:=inttostr(2);

if b=1 then memo.Text:=edit1.Text;

end;

procedure TForm1.FormCreate(Sender: TObject);

begin

memo.text:=' ';

end;

end.

 

задача №3

unit Unit1;

interface

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls;

type

  TForm1 = class(TForm)

    Edit1: TEdit;

    ScrollBar1: TScrollBar;

    procedure ScrollBar1Change(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

var

  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ScrollBar1Change(Sender: TObject);

begin

edit1.Width:=scrollbar1.Position*5;

end;

end.

 

 задача №4

unit Unit1;

interface

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, Menus;

type

  TForm1 = class(TForm)

    MainMenu1: TMainMenu;

    N1: TMenuItem;

    N2: TMenuItem;

    N3: TMenuItem;

    procedure N3Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

var

  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.N3Click(Sender: TObject);

begin

application.terminate;

end;

end.

 

  задача №5

unit Unit1;

interface

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls;

type

  TForm1 = class(TForm)

    Edit1: TEdit;

    Button1: TButton;

    SaveDialog1: TSaveDialog;

    procedure Button1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

var

  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

var f:textfile;

begin

savedialog1.DefaultExt:='txt';

savedialog1.Filter:='текстовый файл(*.txt)|*.txt';

if savedialog1.Execute then begin

assignfile(f, savedialog1.FileName);

rewrite(f);

write(f,edit1.Text);

end;

closefile(f);

end;

end.

 

 задача №6

unit Unit1;

interface

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, Menus, StdCtrls;

type

  TForm1 = class(TForm)

    CheckBox1: TCheckBox;

    PopupMenu1: TPopupMenu;

    N1: TMenuItem;

    N2: TMenuItem;

    N3: TMenuItem;

    procedure N1Click(Sender: TObject);

    procedure N2Click(Sender: TObject);

    procedure N3Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

var

  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.N1Click(Sender: TObject);

begin

checkbox1.Color:=clred;

checkbox1.font.Color:=clgreen;

end;

procedure TForm1.N2Click(Sender: TObject);

begin

checkbox1.Color:=clblack;

checkbox1.font.Color:=clwhite;

end;

procedure TForm1.N3Click(Sender: TObject);

begin

checkbox1.Color:=clwhite;

checkbox1.font.Color:=clblack;

end;

end.

 

 задача №7

unit Unit1;

interface

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls, ExtCtrls;

type

  TForm1 = class(TForm)

    x: TEdit;

    y: TEdit;

    z: TEdit;

    Label1: TLabel;

    Label2: TLabel;

    Label3: TLabel;

    Label4: TLabel;

    RadioGroup1: TRadioGroup;

    Label5: TLabel;

    Button1: TButton;

    procedure Button1Click(Sender: TObject);

    private

    { Private declarations }

  public

    { Public declarations }

  end;

var

  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

begin

if RadioGroup1.Itemindex=0 then

label5.Caption:=inttostr(strtoint(x.text)+strtoint(y.text)+strtoint(z.text))

  else if RadioGroup1.Itemindex=1 then

label5.Caption:=inttostr(strtoint(x.text)*strtoint(y.text)*strtoint(z.text))

else if RadioGroup1.ItemIndex=2 then

label5.Caption:=inttostr(sqr(strtoint(x.text))+sqr(strtoint(y.text))+sqr(strtoint(z.text)))

else label5.Caption:=inttostr(error);

end;

end.

 

 задача №8

unit Unit1;

interface

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls, ExtCtrls;

type

  TForm1 = class(TForm)

    ListBox1: TListBox;

    Button1: TButton;

    Image1: TImage;

    procedure Button1Click(Sender: TObject);

   private

    { Private declarations }

  public

    { Public declarations }

  end;

var

  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

begin

Image1.Picture.LoadFromFile(listbox1.items[listbox1.itemindex]);

end;

end.

 

задача №9

unit Unit1;

interface

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, Grids, StdCtrls;

type

  TForm1 = class(TForm)

    StringGrid1: TStringGrid;

    Edit2: TEdit;

    Label3: TLabel;

    Edit3: TEdit;

    Label4: TLabel;

    Button1: TButton;

    procedure FormCreate(Sender: TObject);

    procedure Button1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

var

  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);

var i:integer;

begin

for i:=1 to 10 do begin

stringgrid1.Cells[0,i]:='команда'+inttostr(i);

stringgrid1.Cells[1,i]:=inttostr(0);

end;

stringgrid1.Cells[1,0]:='очки';

end;

procedure TForm1.Button1Click(Sender: TObject);

var t,m,s,max:integer;

     rab:string;

begin

t:=strtoint(edit2.Text);

m:=strtoint(edit3.Text);

StringGrid1.Cells[1,t]:= inttostr(m);

end;

 end.

 

 задача №10

unit Unit1;

interface

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, TeEngine, Series, StdCtrls, ExtCtrls, TeeProcs, Chart;

type

  TForm1 = class(TForm)

    Chart1: TChart;

    Button1: TButton;

    Series1: TPointSeries;

    OpenDialog1: TOpenDialog;

    procedure Button1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

var

  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

var f:textfile;

    b:array [1..10] of double;

    a:array [1..10] of string;

      i:integer;

begin

opendialog1.DefaultExt:='txt';

opendialog1.Filter:='*.txt|*.txt';

if opendialog1.Execute then

assignfile(f, opendialog1.FileName);

reset(f);

for i:=1 to 10 do begin

readln(f,a[i]);

b[i]:=strtoint(a[i]);

end;

chart1.Series[0].AddArray(b);

Логическая схема юниты 5.doc

— 26.00 Кб (Просмотреть файл, Скачать файл)

Документ Microsoft Office Word.docx

— 12.37 Кб (Просмотреть файл, Скачать файл)

Информация о работе Программирование на языках высокого уровня