domingo, 20 de janeiro de 2019

FMX - Pesquisando um número num vetor





//Pesquisando um número num vetor
//---------------------------------------------------------------------------

#include <fmx.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.fmx"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}

// ---------------------------------------------------------------------------
void __fastcall TForm1::FormShow_1(TObject *Sender, TCanvas *Canvas, const TRectF &ARect)

{
Label2->Text = "PESQUISANDO UM NÚMERO NUM VETOR";
String str_1 = " ";
String str_2 = " ";
int a = 0;
int A [ 100 ], i;
    for( i = 0; i < 100; i++ ) {
A [ a ] =  i;
        a++;
}
int n = 55;
for ( a = 0; a < 100; a++ ) {
str_1 += " ";
str_2 += "     ";
if ( A [ a ] % 10 == 0 ) {
str_1 += ( "\n" );
str_2 += ( "\n" );
}
if ( A [ a ] >= 0 && A [ a ] < 10 ) {
str_1 += ( "0" );
}

str_1 += A [ a ];
if ( A [ a ] == n ) {
if ( A [ a ] >= 0 && A [ a ] < 10 )
str_2 += ( "0" );
str_2 += A [ a ];
}
}
//Declara dois TLabel no form para imprimir
  label->Text = str_1;
  Label1->Text = str_2;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <FMX.Controls.hpp>
#include <FMX.Forms.hpp>
#include <FMX.Objects.hpp>
#include <FMX.Types.hpp>
#include <FMX.Controls.Presentation.hpp>
#include <FMX.StdCtrls.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TRectangle *Rectangle1;
TLabel *label;
TLabel *Label1;
TLabel *Label2;
void __fastcall FormShow_1(TObject *Sender, TCanvas *Canvas, const TRectF &ARect);

private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif


object Form1: TForm1
  Left = 320
  Top = 192
  Caption = 'PESQUISANDO UM N'#218'MERO NUM VETOR'
  ClientHeight = 300
  ClientWidth = 600
  Position = Designed
  FormFactor.Width = 320
  FormFactor.Height = 480
  FormFactor.Devices = [Desktop]
  OnPaint = FormShow_1
  Left = 320
  Top = 192
  DesignerMasterStyle = 0
  object Rectangle1: TRectangle
    Fill.Color = claNull
    Size.Width = 600.000000000000000000
    Size.Height = 300.000000000000000000
    Size.PlatformDefault = False
    Stroke.Color = claRed
    Stroke.Thickness = 10.000000000000000000
  end
  object label: TLabel
    StyledSettings = [Family, Style]
    Position.X = 192.000000000000000000
    Position.Y = 32.000000000000000000
    Size.Width = 265.000000000000000000
    Size.Height = 245.000000000000000000
    Size.PlatformDefault = False
    TextSettings.Font.Size = 16.000000000000000000
    TextSettings.FontColor = claBlue
    TextSettings.VertAlign = Leading
  end
  object Label1: TLabel
    StyledSettings = [Family, Style]
    Position.X = 191.000000000000000000
    Position.Y = 32.000000000000000000
    Size.Width = 265.000000000000000000
    Size.Height = 245.000000000000000000
    Size.PlatformDefault = False
    TextSettings.Font.Size = 16.000000000000000000
    TextSettings.VertAlign = Leading
    TextSettings.WordWrap = False
  end
  object Label2: TLabel
    StyledSettings = [Style]
    Position.X = 120.000000000000000000
    Position.Y = 16.000000000000000000
    Size.Width = 393.000000000000000000
    Size.Height = 16.000000000000000000
    Size.PlatformDefault = False
    TextSettings.Font.Size = 20.000000000000000000
    TextSettings.FontColor = claDeeppink
    TabOrder = 0
  end
end

Nenhum comentário:

Postar um comentário

Observação: somente um membro deste blog pode postar um comentário.