Esta tabuada usa uma janela gráfica
feita no Embarcadero C++ Builder,
se você usa esta poderosa IDE,
não deixe de testar este código,
quem é oferecido aos iniciantes de C/C++.
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
int y = 1;
void __fastcall TForm1::OnPaint ( TObject *Sender ) {
Canvas -> Font -> Style = TFontStyles() << fsBold << fsUnderline << fsItalic;
Canvas -> Font -> Size = 16;
Canvas -> Font -> Name = "Arial";
Canvas -> Brush -> Color = static_cast <TColor> ( RGB ( 0, 191, 255 ) );
Canvas -> Pen -> Width = 10;
Canvas -> Rectangle ( 05, 05, 610, 465 );
SetTextColor ( Canvas->Handle, RGB ( 255, 25, 2 ) );
Canvas -> TextOut ( 140, 10, "C++ BUILDER - CRIANDO TABUADA" );
int i = 0, x = 0, k = 0, w = 0;
String str_1;
String str_2;
String str_3;
do {
x = 1;
for ( i = 1; i <= 10; i++ ) {
k = y;
w = k * x;
str_1 = k;
str_2 = x;
str_3 = w;
if ( k == 1 ) {
ListBox1 -> Items -> Add ( str_1 + " " + "x" +
" " + str_2 + " " + "=" + " " + str_3 );
}
if ( k == 2 ) {
ListBox2 -> Items -> Add ( str_1 + " " + "x" +
" " + str_2 + " " + "=" + " " + str_3 );
}
if ( k == 3 ) {
ListBox3 -> Items -> Add ( str_1 + " " + "x" +
" " + str_2 + " " + "=" + " " + str_3 );
}
if ( k == 4 ) {
ListBox4 -> Items -> Add ( str_1 + " " + "x" +
" " + str_2 + " " + "=" + " " + str_3 );
}
if ( k == 5 ) {
ListBox5 -> Items -> Add ( str_1 + " " + "x" +
" " + str_2 + " " + "=" + " " + str_3 );
}
if ( k == 6 ) {
ListBox6 -> Items -> Add ( str_1 + " " + "x" +
" " + str_2 + " " + "=" + " " + str_3 );
}
if ( k == 7 ) {
ListBox7 -> Items -> Add ( str_1 + " " + "x" +
" " + str_2 + " " + "=" + " " + str_3 );
}
if ( k == 8 ) {
ListBox8 -> Items -> Add ( str_1 + " " + "x" +
" " + str_2 + " " + "=" + " " + str_3 );
}
if ( k == 9 ) {
ListBox9 -> Items -> Add ( str_1 + " " + "x" +
" " + str_2 + " " + "=" + " " + str_3 );
}
if ( k == 10 ) {
ListBox10 -> Items -> Add ( str_1 + " " + "x" +
" " + str_2 + " " + "=" + " " + str_3 );
}
i++;
//ShowMessage ( "Pressione o botão OK" );
x++;
i = i - 1;
}
y++;
} while ( y <= 10 );
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TListBox *ListBox1;
TListBox *ListBox2;
TListBox *ListBox3;
TListBox *ListBox4;
TListBox *ListBox5;
TListBox *ListBox6;
TListBox *ListBox7;
TListBox *ListBox8;
TListBox *ListBox9;
TListBox *ListBox10;
void __fastcall OnPaint(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
object Form1: TForm1
Left = 0
Top = 0
Caption = 'C++ BUILDER - CRIANDO TABUADA'
ClientHeight = 469
ClientWidth = 614
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnPaint = OnPaint
PixelsPerInch = 96
TextHeight = 13
object ListBox1: TListBox
Left = 24
Top = 40
Width = 97
Height = 201
Color = clAqua
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = [fsItalic]
ItemHeight = 19
ParentFont = False
TabOrder = 0
end
object ListBox2: TListBox
Left = 135
Top = 40
Width = 97
Height = 201
Color = clAqua
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = [fsItalic]
ItemHeight = 19
ParentFont = False
TabOrder = 1
end
object ListBox3: TListBox
Left = 248
Top = 40
Width = 97
Height = 201
Color = clAqua
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = [fsItalic]
ItemHeight = 19
ParentFont = False
TabOrder = 2
end
object ListBox4: TListBox
Left = 360
Top = 40
Width = 97
Height = 201
Color = clAqua
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = [fsItalic]
ItemHeight = 19
ParentFont = False
TabOrder = 3
end
object ListBox5: TListBox
Left = 472
Top = 40
Width = 120
Height = 201
Color = clAqua
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = [fsItalic]
ItemHeight = 19
ParentFont = False
TabOrder = 4
end
object ListBox6: TListBox
Left = 24
Top = 256
Width = 97
Height = 201
Color = clAqua
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = [fsItalic]
ItemHeight = 19
ParentFont = False
TabOrder = 5
end
object ListBox7: TListBox
Left = 135
Top = 256
Width = 97
Height = 201
Color = clAqua
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = [fsItalic]
ItemHeight = 19
ParentFont = False
TabOrder = 6
end
object ListBox8: TListBox
Left = 248
Top = 256
Width = 97
Height = 201
Color = clAqua
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = [fsItalic]
ItemHeight = 19
ParentFont = False
TabOrder = 7
end
object ListBox9: TListBox
Left = 360
Top = 256
Width = 97
Height = 201
Color = clAqua
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = [fsItalic]
ItemHeight = 19
ParentFont = False
TabOrder = 8
end
object ListBox10: TListBox
Left = 472
Top = 256
Width = 120
Height = 201
Color = clAqua
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = [fsItalic]
ItemHeight = 19
ParentFont = False
TabOrder = 9
end
end
Nenhum comentário:
Postar um comentário
Observação: somente um membro deste blog pode postar um comentário.