Topshiriqlar bajarish na`munasi.
Bizga quyidagi funksiyaning grafigini yasash bеrilgan bo`lsin.
U=Cosx+x x[0;]; n=80,
Avvalom bor biz bu masalaning algoritm blok-sxеmasini tuzib olamiz. Ya`ni u quyidagicha bo`ladi:
Borland C++ tilidagi forma va dastur ko`rinishi
//--------------------------------------------------------------------------- #include
#include #pragma hdrstop
#include "Unit1.h"
//--------------------------------------------------------------------------- #pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{}
//--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender)
{
float y,x,e;
int z,w;
Image1->Canvas->MoveTo(320,0);
Image1->Canvas->LineTo(320,480);
Image1->Canvas->MoveTo(0,240); Image1->Canvas->LineTo(640,240);
z=320;
w=240;
for(x=0;x<=3.14;x+=3.14/60) { y=cos(x)+x;
Image1->Canvas->MoveTo(z,w);
Image1->Canvas->LineTo(320+x*50,240-y*50); z=320+x*50;
w=240-y*50; } }
//---------------------------------------------------------------------------
O’zbekiston Respublikasi bayrog’i grafigi
//--------------------------------------------------------------------------- #include #pragma hdrstop
#include "Unit1.h"
//--------------------------------------------------------------------------- #pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{}
//--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender)
{
Canvas->Pen->Color = clBlue;
Canvas->Brush->Color = clBlue;
Canvas->Rectangle(70,50,600,150);
// oy chizish
Canvas->Pen->Color = clBlue;
Canvas->Brush->Color = clWhite;
Canvas->Ellipse(80,55,170,145); Canvas->Pen->Color = clBlue;
Canvas->Brush->Color = clBlue;
Canvas->Ellipse(105,55,195,145);
// yulduz chizish
Canvas->Font->Name = "Monotype Corsiva"; Canvas->Font->Color = clWhite;
Canvas->Font->Size = 28;
Canvas->TextOut(180,60," ***");
Canvas->TextOut(180,85,"****");
Canvas->TextOut(165,110,"*****");
Canvas->Pen->Color = clRed;
Canvas->Brush->Color = clRed;
Canvas->Rectangle(70,150,600,160);
Canvas->Pen->Color = clWhite;
Canvas->Brush->Color = clWhite;
Canvas->Rectangle(70,160,600,260);
Canvas->Pen->Color = clRed;
Canvas->Brush->Color = clRed;
Canvas->Rectangle(70,260,600,270);
Canvas->Pen->Color = clGreen;
Canvas->Brush->Color = clGreen;
Canvas->Rectangle(70,270,600,370);
}
//--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender)
{ Close(); //dasturdan chiqish.}
//---------------------------------------------------------------------------
Do'stlaringiz bilan baham: |