Задание
Разработать программу, которая позволяет открывать табличные данные из файла и записывать содержимое таблицы в файл. Размер рабочей области – 5х5 ячеек, ширина фиксированных областей - 1
Delphi
Сообщений 1 страница 10 из 10
Поделиться12011-06-06 11:57:11
Поделиться22011-06-06 11:58:07
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure SaveGrid(Grid:TStringGrid;FileName:string);
var
f: textfile;
x, y: integer;
begin
assignfile(f,Filename);
rewrite(f);
writeln(f, grid.colcount);
writeln(f, grid.rowcount);
for X := 0 to grid.colcount - 1 do
for y := 0 to grid.rowcount - 1 do
writeln(F, grid.cells[x, y]);
closefile(f);
end;
procedure LoadGrid(Grid:TStringGrid;FileName:string);
var
f: textfile;
temp, x, y: integer;
tempstr: string;
begin
assignfile(f, Filename);
reset(f);
readln(f, temp);
grid.colcount := temp;
readln(f, temp);
grid.rowcount := temp;
for X := 0 to grid.colcount - 1 do
for y := 0 to grid.rowcount - 1 do
begin
readln(F, tempstr);
grid.cells[x, y] := tempstr;
end;
closefile(f);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
SaveGrid(form1.StringGrid1,'save.txt');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
LoadGrid(form1.StringGrid1,'Text.txt');
end;
end.Поделиться32011-06-06 12:10:42
Задание: Написать программу, которая в начале генерирует
1)температуру теплоносителя на входе в диапазоне от 70...90 С
2)температуру потока на входе в диапазоне от 10...20 С
температуру теплоносителя на выходе принять равной 50 С
В программу вставить рисунок, подключить таймер (прога должна работать в реальном времени), также подключить progressbar
По данному уравнению 0.5*(t1-t3)+t2 прога должна считать температуру потока на выходе, где t1-температуру теплоносителя на входе в диапазоне от 70...90 С;
t2- температуру потока на входе в диапазоне от 10...20 С
t3- температуру теплоносителя на выходе принять равной 50 С
Поделиться42011-06-06 12:11:06
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, jpeg, ExtCtrls,Math, ComCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
GroupBox1: TGroupBox;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Timer1: TTimer;
ProgressBar1: TProgressBar;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
Const t3=50;
var
t1,t2,t4:real;
begin
t1:=RandomRange(70, 90);
Label2.caption:=floattostr(t1);
t2:=RandomRange(10, 20);
Label4.caption:=floattostr(t2);
Label6.caption:=floattostr(t3);
t4:=Round(1000*(0.5*(t1-t3)+t2))/1000;
Label7.caption:=floattostr(t4);
progressbar1.Position := progressbar1.Position + 25;
if progressbar1.Position = 300 then progressbar1.Position :=0;
end;
end.Поделиться52011-06-06 12:15:14
Задание: Написать программу, которая будет строить графики каналов, данные для посторения графика должны считываться с .txt файла ( в файле находится набор чисел, графики будут -прямые)
Поделиться62011-06-06 12:15:41
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: TLineSeries;
Series2: TLineSeries;
Series3: TLineSeries;
Series4: TLineSeries;
Series5: TLineSeries;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
j,i:integer;
f:Textfile;
a:array[1..50] of real;
begin
AssignFile(f,'Text.txt');
reset(f);
for j:=1 to 50 do begin
Readln(f,a[j]);
end;
for j:=1 to 50 do begin
Series1.Add(a[1],'');
Series2.Add(a[2],'');
Series3.Add(a[3],'');
Series4.Add(a[4],'');
Series5.Add(a[5],'');
end;
end;
end.Поделиться72011-06-06 12:18:23
Задание: Написать программу вывода 8 прямоугольников, закрашеных разными стилями
Поделиться82011-06-06 12:18:47
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
// перерисовка формы
procedure TForm1.FormCreate(Sender: TObject);
const
bsName: array[1..8] of string =
('bsSolid','bsClear','bsHorizontal',
'bsVertical','bsFDiagonal','bsBDiagonal',
'bsCross','bsDiagCross');
var
x,y: integer; // координаты левого верхнего угла прямоугольника
w,h: integer; // ширина и высота прямоугольника
bs: TBrushStyle;// стиль заполнения области
k: integer; // номер стиля заполнения
i,j: integer;
begin
w:=40; h:=40; // размер области(прямоугольника)
y:=70;
for i:=1 to 2 do
begin
x:=10;
for j:=1 to 4 do
begin
k:=j+(i-1)*4; // номер стиля заполнения
case k of
1: bs:= bsSolid;
2: bs:= bsClear;
3: bs:= bsHorizontal;
4: bs:= bsVertical;
5: bs:= bsFDiagonal;
6: bs:= bsBDiagonal;
7: bs:= bsCross;
8: bs:= bsDiagCross;
end;
// вывод прямоугольника
Image1.Canvas.Brush.Color := clGreen;
// цвет закрашивания - зеленый
Image1.Canvas.Brush.Style := bs;
// стиль закрашивания
Image1.Canvas . Rectangle (x, y, x+w, y-1-h) ;
// вывод названия стиля
Image1.Canvas.Brush.Style := bsClear;
Image1.Canvas.TextOut(x, y-60, bsName[k]);
// вывод названия стиля
x := x+w+30;
end;
y := y+h+30;
end;
end;
end.Поделиться92011-06-06 12:21:26
Задание: Написать программу, которая при кликаньи на форму рисует рисунок
Поделиться102011-06-06 12:21:49
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 = class(TForm)
PaintBox1: TPaintBox;
procedure PaintBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.PaintBox1Click(Sender: TObject);
begin
PaintBox1.Canvas.MoveTo(30,10);
PaintBox1.Canvas.Lineto(300,10);
PaintBox1.Canvas.MoveTo(30,20);
PaintBox1.Canvas.Lineto(300,20);
PaintBox1.Canvas.MoveTo(30,20);
PaintBox1.Canvas.Lineto(300,20);
PaintBox1.Canvas.MoveTo(30,60);
PaintBox1.Canvas.Lineto(300,60);
PaintBox1.Canvas.MoveTo(30,70);
PaintBox1.Canvas.Lineto(300,70);
PaintBox1.Canvas.Rectangle(150,0,200,90);
PaintBox1.Canvas.MoveTo(150,35);
PaintBox1.Canvas.Lineto(200,35);
PaintBox1.Canvas.MoveTo(150,40);
PaintBox1.Canvas.Lineto(200,40);
PaintBox1.Canvas.MoveTo(150,45);
PaintBox1.Canvas.Lineto(200,45);
PaintBox1.Canvas.MoveTo(150,50);
PaintBox1.Canvas.Lineto(200,50);
PaintBox1.Canvas.MoveTo(150,55);
PaintBox1.Canvas.Lineto(200,55);
PaintBox1.Canvas.MoveTo(150,60);
PaintBox1.Canvas.Lineto(200,60);
PaintBox1.Canvas.MoveTo(150,65);
PaintBox1.Canvas.Lineto(200,65);
PaintBox1.Canvas.Ellipse(250,55,270,75);
PaintBox1.Canvas.MoveTo(258,75);
PaintBox1.Canvas.Lineto(258,110);
PaintBox1.Canvas.MoveTo(262,75);
PaintBox1.Canvas.Lineto(262,110)
end;
end.