Se você é iniciante em C/C++,
e gostaria de usar janelas gráficas
em seus programas porque já não aguenta mais
a janelinha preta do cmd ( Prompt de comando),
baixe agora mesmo e instale o Embarcadero
C++ Builder, crie e personalize toda interface
gráfica para seus programas ainda hoje.
//---------------------------------------------------------------------------
//Pares e ímpares em duas cores
#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 = "PARES E ÍMPARES EM VETOR";
String str_1 = " ";
String str_2 = " ";
int a = 0, b = 0;
int A [ 10 ] [ 10 ], i;
for( i = 0; i < 100; i++ ) {
A [ b ] [ a ] = i;
a++;
}
for ( a = 0; a < 10; a++ ) {
for ( b = 0; b < 10; b++ ) {
if ( A [ a ] [ b ] % 10 == 0 ) {
str_1 += ( "\n" );
str_2 += ( "\n" );
}
if ( A [ a ] [ b ] % 2 == 1 ) {
str_1 += " ";
if ( A [ a ] [ b ] >= 0 && A [ a ] [ b ] < 10 )
str_1 += ( "0" );
str_1 += A [ a ] [ b ];
}
else {
str_2 += " ";
if ( A [ a ] [ b ] >= 0 && A [ a ] [ b ] < 10 )
str_2 += ( "0" );
str_2 += A [ a ] [ b ];
}
}
}
//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 = 'PARES E '#195#141'MPARES EM 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 = claBlue
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 = 165.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 = 200.000000000000000000
Position.Y = 16.000000000000000000
Size.Width = 329.000000000000000000
Size.Height = 16.000000000000000000
Size.PlatformDefault = False
TextSettings.Font.Size = 20.000000000000000000
TextSettings.FontColor = claDeeppink
TabOrder = 0
end
end
Fala mano, parabéns pela iniciativa. Poderia fazer uns tutoriais e lançar no YouTube.
ResponderExcluirEste é o objetivo, mas o ambiente por aqui é muito barulhento,
Excluirnem sei como vou fazer isto