Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > IT форум > Помощь студентам
Регистрация

Восстановить пароль

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 04.01.2013, 22:10   #1
StudentMarat
Форумчанин
 
Регистрация: 10.10.2008
Сообщений: 123
По умолчанию Дорешить простую задачу.

Помогите до конца решить задачу. Я ее уже на 90% выполнил. Привожу код

Код:
var
  Form2: TForm2;
  x,y,x2,y2: integer;

procedure TForm2.Button2Click(Sender: TObject);
var
a,b,c,d:integer;
bs: TBrushStyle;
begin
if (edit1.Text='') or (edit2.Text='') or (edit3.Text='') or (edit4.Text='')then
begin
messagedlg('Не все данные введены',mtError,[mbOk],0)
end
else begin
  x:=250;
  y:=250;
  x2:=250;
  y2:=250;
  a:=StrToInt(Edit1.Text);
  b:=StrToInt(Edit2.Text);
  c:=StrToInt(Edit3.Text);
  d:=StrToInt(Edit4.Text);
if (a<0) and (b<0) then begin
  x:=x+a;
  y:=y-b;
  end;
if (c<0) and (d<0) then begin
  x2:=x2+c;
  y2:=y2-d;
  end;

  if (a>=0) and (b>=0) then begin
  x:=x+a;
  y:=y-b;
  end;

  if (c>=0) and (d>=0) then begin
 x2:=x2+c;
 y2:=y2-d;
  end;

  if (a<0) and (b>=0) then begin
  x:=x+a;
  y:=y-b;
  end;

 if (c<0) and (d>=0) then begin
  x2:=x2+c;
 y2:=y2-d;
 end;

  if (a>=0) and (b<0) then begin
  x:=x+a;
  y:=y-b;
  end;

  if (c>=0) and (d<0) then begin
  x2:=x2+c;
  y2:=y2-d;
  end;


  If (x>=250)and (y<=250)and(x2>=250) and (y2<=250)then
    begin
     ListBox1.Items.Text:='1';
     image1.Canvas.Brush.Color:=clGreen;        // Зеленый
     Image1.Canvas.Rectangle(X,Y,X2,Y2);
    Image1.Canvas.Brush.Style:=bsClear;
    end;

    If (x<=250)and (y<=250)and(x2<=250) and (y2<=250)then
    begin
     ListBox1.Items.Text:='2';
     image1.Canvas.Brush.Color:=clBlue;       //Синий
     Image1.Canvas.Rectangle(X,Y,X2,Y2);
     Image1.Canvas.Brush.Style:=bsClear;
    end;

  If (x<=250) and(y>=250)and(x2<=250) and (y2>=250)then
    begin
      ListBox1.Items.Text:='3';
      image1.Canvas.Brush.Color:=clRed;       //Красный
     Image1.Canvas.Rectangle(X,Y,X2,Y2);
     Image1.Canvas.Brush.Style:=bsClear;
    end;

  If (x>=250)and (y>=250)and(x2>=250) and (y2>=250)then
    begin
    ListBox1.Items.Text:='4';
    image1.Canvas.Brush.Color:=clYellow;        //Желтый
     Image1.Canvas.Rectangle(X,Y,X2,Y2);
     Image1.Canvas.Brush.Style:=bsClear;
    end;

    If ((x>250)and (y<250)and(x2<250) and (y2<250)) or ((x<250) and (y<250) and (x2>250) and (y2<250))then
    begin
     ListBox1.Items.Text:='1,2';
     bs:=Image1.Canvas.Brush.Style;
     Image1.Canvas.Brush.Style:=bsClear;
     Image1.Canvas.Rectangle(X,Y,X2,Y2);

     image1.Canvas.Brush.Color:=clGreen;
    Image1.Canvas.Rectangle(x,y,250,y2);

     image1.Canvas.Brush.Color:=clBlue;
     Image1.Canvas.Rectangle(x2,y2,250,y);

     Image1.Canvas.Brush.Style:=bs;
    end;

    If ((x<250)and(y<250)and(x2<250)and(y2>250)) or ((x<250) and (y>250) and (x2<250) and (y2<250))then
    begin
       ListBox1.Items.Text:='2,3';
       bs:=Image1.Canvas.Brush.Style;
       Image1.Canvas.Brush.Style:=bsClear;
       Image1.Canvas.Rectangle(X,Y,X2,Y2);

       image1.Canvas.Brush.Color:=clBlue;
       Image1.Canvas.Rectangle(x,y,x2,250);

       image1.Canvas.Brush.Color:=clRed;
       Image1.Canvas.Rectangle(x2,y2,x,250);

       Image1.Canvas.Brush.Style:=bs;
    end;

  If ((x<250)and(y>250)and(x2>250)and(y2>250)) or ((x>250) and (y>250) and (x2<250) and (y2>250))then
    begin
      ListBox1.Items.Text:='3,4';
       bs:=Image1.Canvas.Brush.Style;
       Image1.Canvas.Brush.Style:=bsClear;
       Image1.Canvas.Rectangle(X,Y,X2,Y2);

        image1.Canvas.Brush.Color:=clYellow;
    Image1.Canvas.Rectangle(x,y,250,y2);

     image1.Canvas.Brush.Color:=clRed;
     Image1.Canvas.Rectangle(x2,y2,250,y);


       Image1.Canvas.Brush.Style:=bs;
    end;

 If ((x>250)and(y>250)and (x2>250)and(y2<250)) or ((x>250) and (y<250) and (x2>250) and (y2>250))then
    begin
      ListBox1.Items.Text:='1,4';
       bs:=Image1.Canvas.Brush.Style;
       Image1.Canvas.Brush.Style:=bsClear;
       Image1.Canvas.Rectangle(X,Y,X2,Y2);

       image1.Canvas.Brush.Color:=clYellow;
       Image1.Canvas.Rectangle(x,y,x2,250);

       image1.Canvas.Brush.Color:=clBlue;
       Image1.Canvas.Rectangle(x2,y2,x,250);

       Image1.Canvas.Brush.Style:=bs;
    end;

    If ((x>250)and(y>250)and(x2<250)and(y2<250)) or ((x<250) and (y<250) and (X2>250) and (y2>250)) or ((x>250) and (y<250) and (x2<250) and (y2>250)) or ((x<250) and (y>250) and (x2>250) and (y2<250))then
    begin
    ListBox1.Items.Text:='1,2,3,4';
      bs:=Image1.Canvas.Brush.Style;
       Image1.Canvas.Brush.Style:=bsClear;
       Image1.Canvas.Rectangle(X,Y,X2,Y2);

       image1.Canvas.Brush.Color:=clGreen;
       Image1.Canvas.Rectangle(x,y,250,250);

       image1.Canvas.Brush.Color:=clBlue;
       Image1.Canvas.Rectangle(x,y2,250,250);

       image1.Canvas.Brush.Color:=clRed;
       Image1.Canvas.Rectangle(x2,y2,250,250);

       image1.Canvas.Brush.Color:=clYellow;
       Image1.Canvas.Rectangle(x2,y,250,250);

       Image1.Canvas.Brush.Style:=bs;
    end;
  end;
end;
Изображения
Тип файла: jpg Безымянный.jpg (85.4 Кб, 126 просмотров)
StudentMarat вне форума Ответить с цитированием
Старый 04.01.2013, 22:11   #2
StudentMarat
Форумчанин
 
Регистрация: 10.10.2008
Сообщений: 123
По умолчанию

Продолжение кода

Код:
procedure TForm2.Clear;
var i, k:integer;
begin
Image1.Canvas.Pen.Width:=1;
Image1.Canvas.pen.Color:=clBlack;
image1.Canvas.Brush.Color:=clwhite;
image1.Canvas.Rectangle(0,0,500,500);
image1.Canvas.MoveTo(250,0); image1.Canvas.LineTo(250,500);
image1.Canvas.MoveTo(0,250); image1.Canvas.LineTo(500,250);
k:=50;
for i:=1 to 9 do begin
image1.Canvas.MoveTo(247,k); image1.Canvas.LineTo(254,k);
image1.Canvas.MoveTo(k,247); image1.Canvas.LineTo(k,254);
image1.Canvas.TextOut(k-9,257,inttostr(k-250));
if k<>250 then image1.Canvas.TextOut(223,k-7,inttostr(-k+250));
k:=k+50;
end;
end;




procedure TForm2.Button1Click(Sender: TObject);
begin
application.Terminate;
end;

procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
application.Terminate;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
Clear;
end;

procedure TForm2.N3Click(Sender: TObject);
begin
ListBox1.Items.Text:='';
Clear;
end;

end.
StudentMarat вне форума Ответить с цитированием
Старый 04.01.2013, 22:12   #3
StudentMarat
Форумчанин
 
Регистрация: 10.10.2008
Сообщений: 123
По умолчанию

Сама задача. Я ее уже выполнил на 90 процентов. Осталось мелочь

Вводятся две точки, являющиеся координатами левого верхнего и правого нижнего углов прямоугольника. Программа определяет (выводит в окне), сколько квадрантов захватывает прямоугольник. Главное меню определяет вершину, ко-ординаты которой должны быть одинакового знака. Сектора прямоугольника в разных квадрантах закрашивается в разные цвета. Запуск графического построения - ввод последней координаты. Очистка исходных данных - клавиша "Esc".

Главное меню определяет вершину, ко-ординаты которой должны быть одинакового знака.
- вот это не знаю как сделать
StudentMarat вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Записи в Делфи.Пожалуйста,помогите дорешить задачу pionerka Помощь студентам 3 12.12.2009 23:23
Помогите решить простую задачу asercbr123 Microsoft Office Excel 4 11.12.2008 13:25
Помогите дорешить задачу с массивами(Pascal) Дима82 Помощь студентам 4 23.05.2008 23:11
Помогите решить простую задачу Teh Общие вопросы Delphi 4 24.04.2008 07:37
Помогите решить простую задачу по C++ steal13 Общие вопросы C/C++ 6 03.01.2008 09:40