Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Отчёт по 2-му (сложному) калькулятору.docx
Скачиваний:
0
Добавлен:
30.09.2026
Размер:
653 Кб
Скачать
☆

3 Текст программы

#pragma once

#include <cmath>

namespace ProjectRamil {

 

    using namespace System;

    using namespace System::ComponentModel;

    using namespace System::Collections;

    using namespace System::Windows::Forms;

    using namespace System::Data;

    using namespace System::Drawing;

 

    /// <summary>

        /// Сводка для MyForm

        /// </summary>

    public ref class FFirst : public System::Windows::Forms::Form

    {

    public:

        FFirst(void)

        {

            InitializeComponent();

            //

            //TODO: Добавьте код конструктора

            //

        }

 

    protected:

        /// <summary>

        /// Освободить все используемые ресурсы

        /// </summary>

        ~FFirst()

        {

            if (components)

            {

                delete components;

            }

        }

    private: System::Windows::Forms::Button^ btnZero;

    private: System::Windows::Forms::Button^ btnPoint;

    private: System::Windows::Forms::Button^ btnPlusMinus;

    private: System::Windows::Forms::Button^ btnPlus;

    private: System::Windows::Forms::Button^ btnOne;

    private: System::Windows::Forms::Button^ btnFour;

    private: System::Windows::Forms::Button^ btnSeven;

    private: System::Windows::Forms::Button^ btnTwo;

    private: System::Windows::Forms::Button^ btnFive;

    private: System::Windows::Forms::Button^ btnEight;

    private: System::Windows::Forms::Button^ btnThree;

    private: System::Windows::Forms::Button^ btnSix;

    private: System::Windows::Forms::Button^ btnNine;

    private: System::Windows::Forms::Button^ btnMinus;

    private: System::Windows::Forms::Button^ btnMultiply;

    private: System::Windows::Forms::Button^ btnDivide;

    private: System::Windows::Forms::Button^ btnEqually;

    private: System::Windows::Forms::Button^ btnInverse;

    private: System::Windows::Forms::Button^ btnPercent;

    private: System::Windows::Forms::Button^ btnSqrt;

    private: System::Windows::Forms::Button^ btnBackspace;

    private: System::Windows::Forms::Button^ btnCE;

    private: System::Windows::Forms::Button^ btnC;

    private: System::Windows::Forms::TextBox^ txtPoleVvoda;

 

    protected:

 

    protected:

 

    private:

        /// <summary>

        ///  Обязательная переменная конструктора.

        /// </summary>

        System::ComponentModel::Container^ components;

 

#pragma region Windows Form Designer generated code

        /// <summary>

        /// Требуемый метод для поддержки конструктора — не изменяйте 

        /// содержимое этого метода с помощью редактора кода.

        /// </summary>

        void InitializeComponent(void)

        {

            this->btnZero = (gcnew System::Windows::Forms::Button());

            this->btnPoint = (gcnew System::Windows::Forms::Button());

            this->btnPlusMinus = (gcnew System::Windows::Forms::Button());

            this->btnPlus = (gcnew System::Windows::Forms::Button());

            this->btnOne = (gcnew System::Windows::Forms::Button());

            this->btnFour = (gcnew System::Windows::Forms::Button());

            this->btnSeven = (gcnew System::Windows::Forms::Button());

            this->btnTwo = (gcnew System::Windows::Forms::Button());

            this->btnFive = (gcnew System::Windows::Forms::Button());

            this->btnEight = (gcnew System::Windows::Forms::Button());

            this->btnThree = (gcnew System::Windows::Forms::Button());

            this->btnSix = (gcnew System::Windows::Forms::Button());

            this->btnNine = (gcnew System::Windows::Forms::Button());

            this->btnMinus = (gcnew System::Windows::Forms::Button());

            this->btnMultiply = (gcnew System::Windows::Forms::Button());

            this->btnDivide = (gcnew System::Windows::Forms::Button());

            this->btnEqually = (gcnew System::Windows::Forms::Button());

            this->btnInverse = (gcnew System::Windows::Forms::Button());

            this->btnPercent = (gcnew System::Windows::Forms::Button());

            this->btnSqrt = (gcnew System::Windows::Forms::Button());

            this->btnBackspace = (gcnew System::Windows::Forms::Button());

            this->btnCE = (gcnew System::Windows::Forms::Button());

            this->btnC = (gcnew System::Windows::Forms::Button());

            this->txtPoleVvoda = (gcnew System::Windows::Forms::TextBox());

            this->SuspendLayout();

            // 

            // btnZero

            // 

            this->btnZero->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnZero->ForeColor = System::Drawing::Color::Black;

            this->btnZero->Location = System::Drawing::Point(12, 272);

            this->btnZero->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnZero->Name = L"btnZero";

            this->btnZero->Size = System::Drawing::Size(55, 50);

            this->btnZero->TabIndex = 0;

            this->btnZero->Text = L"0";

            this->btnZero->UseVisualStyleBackColor = true;

            this->btnZero->Click += gcnew System::EventHandler(this, &FFirst::Numbers);

            // 

            // btnPoint

            // 

            this->btnPoint->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnPoint->ForeColor = System::Drawing::Color::Black;

            this->btnPoint->Location = System::Drawing::Point(73, 272);

            this->btnPoint->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnPoint->Name = L"btnPoint";

            this->btnPoint->Size = System::Drawing::Size(55, 50);

            this->btnPoint->TabIndex = 10;

            this->btnPoint->Text = L",";

            this->btnPoint->UseVisualStyleBackColor = true;

            this->btnPoint->Click += gcnew System::EventHandler(this, &FFirst::btnPoint_Click);

            // 

            // btnPlusMinus

            // 

            this->btnPlusMinus->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnPlusMinus->ForeColor = System::Drawing::Color::Black;

            this->btnPlusMinus->Location = System::Drawing::Point(133, 272);

            this->btnPlusMinus->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnPlusMinus->Name = L"btnPlusMinus";

            this->btnPlusMinus->Size = System::Drawing::Size(55, 50);

            this->btnPlusMinus->TabIndex = 11;

            this->btnPlusMinus->Text = L"+\\-";

            this->btnPlusMinus->UseVisualStyleBackColor = true;

            this->btnPlusMinus->Click += gcnew System::EventHandler(this, &FFirst::btnPlusMinus_Click);

            // 

            // btnPlus

            // 

            this->btnPlus->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnPlus->ForeColor = System::Drawing::Color::Red;

            this->btnPlus->Location = System::Drawing::Point(195, 272);

            this->btnPlus->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnPlus->Name = L"btnPlus";

            this->btnPlus->Size = System::Drawing::Size(55, 50);

            this->btnPlus->TabIndex = 12;

            this->btnPlus->Text = L"+";

            this->btnPlus->UseVisualStyleBackColor = true;

            this->btnPlus->Click += gcnew System::EventHandler(this, &FFirst::arifmOperations);

            // 

            // btnOne

            // 

            this->btnOne->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnOne->ForeColor = System::Drawing::Color::Black;

            this->btnOne->Location = System::Drawing::Point(12, 217);

            this->btnOne->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnOne->Name = L"btnOne";

            this->btnOne->Size = System::Drawing::Size(55, 50);

            this->btnOne->TabIndex = 1;

            this->btnOne->Text = L"1";

            this->btnOne->UseVisualStyleBackColor = true;

            this->btnOne->Click += gcnew System::EventHandler(this, &FFirst::Numbers);

            // 

            // btnFour

            // 

            this->btnFour->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnFour->ForeColor = System::Drawing::Color::Black;

            this->btnFour->Location = System::Drawing::Point(12, 160);

            this->btnFour->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnFour->Name = L"btnFour";

            this->btnFour->Size = System::Drawing::Size(55, 50);

            this->btnFour->TabIndex = 4;

            this->btnFour->Text = L"4";

            this->btnFour->UseVisualStyleBackColor = true;

            this->btnFour->Click += gcnew System::EventHandler(this, &FFirst::Numbers);

            // 

            // btnSeven

            // 

            this->btnSeven->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnSeven->ForeColor = System::Drawing::Color::Black;

            this->btnSeven->Location = System::Drawing::Point(12, 103);

            this->btnSeven->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnSeven->Name = L"btnSeven";

            this->btnSeven->Size = System::Drawing::Size(55, 50);

            this->btnSeven->TabIndex = 7;

            this->btnSeven->Text = L"7";

            this->btnSeven->UseVisualStyleBackColor = true;

            this->btnSeven->Click += gcnew System::EventHandler(this, &FFirst::Numbers);

            // 

            // btnTwo

            // 

            this->btnTwo->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnTwo->ForeColor = System::Drawing::Color::Black;

            this->btnTwo->Location = System::Drawing::Point(73, 217);

            this->btnTwo->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnTwo->Name = L"btnTwo";

            this->btnTwo->Size = System::Drawing::Size(55, 50);

            this->btnTwo->TabIndex = 2;

            this->btnTwo->Text = L"2";

            this->btnTwo->UseVisualStyleBackColor = true;

            this->btnTwo->Click += gcnew System::EventHandler(this, &FFirst::Numbers);

            // 

            // btnFive

            // 

            this->btnFive->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnFive->ForeColor = System::Drawing::Color::Black;

            this->btnFive->Location = System::Drawing::Point(73, 160);

            this->btnFive->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnFive->Name = L"btnFive";

            this->btnFive->Size = System::Drawing::Size(55, 50);

            this->btnFive->TabIndex = 5;

            this->btnFive->Text = L"5";

            this->btnFive->UseVisualStyleBackColor = true;

            this->btnFive->Click += gcnew System::EventHandler(this, &FFirst::Numbers);

            // 

            // btnEight

            // 

            this->btnEight->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnEight->ForeColor = System::Drawing::Color::Black;

            this->btnEight->Location = System::Drawing::Point(73, 103);

            this->btnEight->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnEight->Name = L"btnEight";

            this->btnEight->Size = System::Drawing::Size(55, 50);

            this->btnEight->TabIndex = 8;

            this->btnEight->Text = L"8";

            this->btnEight->UseVisualStyleBackColor = true;

            this->btnEight->Click += gcnew System::EventHandler(this, &FFirst::Numbers);

            // 

            // btnThree

            // 

            this->btnThree->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnThree->ForeColor = System::Drawing::Color::Black;

            this->btnThree->Location = System::Drawing::Point(133, 217);

            this->btnThree->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnThree->Name = L"btnThree";

            this->btnThree->Size = System::Drawing::Size(55, 50);

            this->btnThree->TabIndex = 3;

            this->btnThree->Text = L"3";

            this->btnThree->UseVisualStyleBackColor = true;

            this->btnThree->Click += gcnew System::EventHandler(this, &FFirst::Numbers);

            // 

            // btnSix

            // 

            this->btnSix->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnSix->ForeColor = System::Drawing::Color::Black;

            this->btnSix->Location = System::Drawing::Point(133, 160);

            this->btnSix->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnSix->Name = L"btnSix";

            this->btnSix->Size = System::Drawing::Size(55, 50);

            this->btnSix->TabIndex = 6;

            this->btnSix->Text = L"6";

            this->btnSix->UseVisualStyleBackColor = true;

            this->btnSix->Click += gcnew System::EventHandler(this, &FFirst::Numbers);

            // 

            // btnNine

            // 

            this->btnNine->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnNine->ForeColor = System::Drawing::Color::Black;

            this->btnNine->Location = System::Drawing::Point(133, 103);

            this->btnNine->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnNine->Name = L"btnNine";

            this->btnNine->Size = System::Drawing::Size(55, 50);

            this->btnNine->TabIndex = 9;

            this->btnNine->Text = L"9";

            this->btnNine->UseVisualStyleBackColor = true;

            this->btnNine->Click += gcnew System::EventHandler(this, &FFirst::Numbers);

            // 

            // btnMinus

            // 

            this->btnMinus->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnMinus->ForeColor = System::Drawing::Color::Red;

            this->btnMinus->Location = System::Drawing::Point(195, 217);

            this->btnMinus->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnMinus->Name = L"btnMinus";

            this->btnMinus->Size = System::Drawing::Size(55, 50);

            this->btnMinus->TabIndex = 14;

            this->btnMinus->Text = L"-";

            this->btnMinus->UseVisualStyleBackColor = true;

            this->btnMinus->Click += gcnew System::EventHandler(this, &FFirst::arifmOperations);

            // 

            // btnMultiply

            // 

            this->btnMultiply->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnMultiply->ForeColor = System::Drawing::Color::Red;

            this->btnMultiply->Location = System::Drawing::Point(195, 160);

            this->btnMultiply->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnMultiply->Name = L"btnMultiply";

            this->btnMultiply->Size = System::Drawing::Size(55, 50);

            this->btnMultiply->TabIndex = 16;

            this->btnMultiply->Text = L"*";

            this->btnMultiply->UseVisualStyleBackColor = true;

            this->btnMultiply->Click += gcnew System::EventHandler(this, &FFirst::arifmOperations);

            // 

            // btnDivide

            // 

            this->btnDivide->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnDivide->ForeColor = System::Drawing::Color::Red;

            this->btnDivide->Location = System::Drawing::Point(195, 103);

            this->btnDivide->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnDivide->Name = L"btnDivide";

            this->btnDivide->Size = System::Drawing::Size(55, 50);

            this->btnDivide->TabIndex = 18;

            this->btnDivide->Text = L"/";

            this->btnDivide->UseVisualStyleBackColor = true;

            this->btnDivide->Click += gcnew System::EventHandler(this, &FFirst::arifmOperations);

            // 

            // btnEqually

            // 

            this->btnEqually->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnEqually->ForeColor = System::Drawing::Color::Red;

            this->btnEqually->Location = System::Drawing::Point(256, 272);

            this->btnEqually->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnEqually->Name = L"btnEqually";

            this->btnEqually->Size = System::Drawing::Size(55, 50);

            this->btnEqually->TabIndex = 13;

            this->btnEqually->Text = L"=";

            this->btnEqually->UseVisualStyleBackColor = true;

            this->btnEqually->Click += gcnew System::EventHandler(this, &FFirst::btnEqually_Click);

            // 

            // btnInverse

            // 

            this->btnInverse->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnInverse->ForeColor = System::Drawing::Color::Red;

            this->btnInverse->Location = System::Drawing::Point(256, 217);

            this->btnInverse->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnInverse->Name = L"btnInverse";

            this->btnInverse->Size = System::Drawing::Size(55, 50);

            this->btnInverse->TabIndex = 15;

            this->btnInverse->Text = L"1/x";

            this->btnInverse->UseVisualStyleBackColor = true;

            this->btnInverse->Click += gcnew System::EventHandler(this, &FFirst::btnInverse_Click);

            // 

            // btnPercent

            // 

            this->btnPercent->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnPercent->ForeColor = System::Drawing::Color::Red;

            this->btnPercent->Location = System::Drawing::Point(256, 160);

            this->btnPercent->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnPercent->Name = L"btnPercent";

            this->btnPercent->Size = System::Drawing::Size(55, 50);

            this->btnPercent->TabIndex = 17;

            this->btnPercent->Text = L"%";

            this->btnPercent->UseVisualStyleBackColor = true;

            this->btnPercent->Click += gcnew System::EventHandler(this, &FFirst::btnPercent_Click);

            // 

            // btnSqrt

            // 

            this->btnSqrt->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnSqrt->ForeColor = System::Drawing::Color::Red;

            this->btnSqrt->Location = System::Drawing::Point(256, 103);

            this->btnSqrt->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnSqrt->Name = L"btnSqrt";

            this->btnSqrt->Size = System::Drawing::Size(55, 50);

            this->btnSqrt->TabIndex = 19;

            this->btnSqrt->Text = L"sqrt";

            this->btnSqrt->UseVisualStyleBackColor = true;

            this->btnSqrt->Click += gcnew System::EventHandler(this, &FFirst::btnSqrt_Click);

            // 

            // btnBackspace

            // 

            this->btnBackspace->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnBackspace->ForeColor = System::Drawing::Color::Red;

            this->btnBackspace->Location = System::Drawing::Point(12, 48);

            this->btnBackspace->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnBackspace->Name = L"btnBackspace";

            this->btnBackspace->Size = System::Drawing::Size(128, 50);

            this->btnBackspace->TabIndex = 20;

            this->btnBackspace->Text = L"Backspace";

            this->btnBackspace->UseVisualStyleBackColor = true;

            this->btnBackspace->Click += gcnew System::EventHandler(this, &FFirst::btnBackspace_Click);

            // 

            // btnCE

            // 

            this->btnCE->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnCE->ForeColor = System::Drawing::Color::Red;

            this->btnCE->Location = System::Drawing::Point(145, 48);

            this->btnCE->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnCE->Name = L"btnCE";

            this->btnCE->Size = System::Drawing::Size(80, 50);

            this->btnCE->TabIndex = 21;

            this->btnCE->Text = L"CE";

            this->btnCE->UseVisualStyleBackColor = true;

            this->btnCE->Click += gcnew System::EventHandler(this, &FFirst::btnCE_Click);

            // 

            // btnC

            // 

            this->btnC->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->btnC->ForeColor = System::Drawing::Color::Red;

            this->btnC->Location = System::Drawing::Point(231, 48);

            this->btnC->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->btnC->Name = L"btnC";

            this->btnC->Size = System::Drawing::Size(80, 50);

            this->btnC->TabIndex = 22;

            this->btnC->Text = L"C";

            this->btnC->UseVisualStyleBackColor = true;

            this->btnC->Click += gcnew System::EventHandler(this, &FFirst::btnC_Click);

            // 

            // txtPoleVvoda

            // 

            this->txtPoleVvoda->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                static_cast<System::Byte>(204)));

            this->txtPoleVvoda->Location = System::Drawing::Point(12, 12);

            this->txtPoleVvoda->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->txtPoleVvoda->Name = L"txtPoleVvoda";

            this->txtPoleVvoda->ReadOnly = true;

            this->txtPoleVvoda->Size = System::Drawing::Size(297, 30);

            this->txtPoleVvoda->TabIndex = 23;

            this->txtPoleVvoda->Text = L"0";

            this->txtPoleVvoda->TextAlign = System::Windows::Forms::HorizontalAlignment::Right;

            this->txtPoleVvoda->TextChanged += gcnew System::EventHandler(this, &FFirst::txtPoleVvoda_TextChanged);

            // 

            // FFirst

            // 

            this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);

            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;

            this->AutoSize = true;

            this->ClientSize = System::Drawing::Size(323, 334);

            this->Controls->Add(this->txtPoleVvoda);

            this->Controls->Add(this->btnC);

            this->Controls->Add(this->btnCE);

            this->Controls->Add(this->btnBackspace);

            this->Controls->Add(this->btnSqrt);

            this->Controls->Add(this->btnPercent);

            this->Controls->Add(this->btnInverse);

            this->Controls->Add(this->btnEqually);

            this->Controls->Add(this->btnDivide);

            this->Controls->Add(this->btnMultiply);

            this->Controls->Add(this->btnMinus);

            this->Controls->Add(this->btnNine);

            this->Controls->Add(this->btnSix);

            this->Controls->Add(this->btnThree);

            this->Controls->Add(this->btnEight);

            this->Controls->Add(this->btnFive);

            this->Controls->Add(this->btnTwo);

            this->Controls->Add(this->btnSeven);

            this->Controls->Add(this->btnFour);

            this->Controls->Add(this->btnOne);

            this->Controls->Add(this->btnPlus);

            this->Controls->Add(this->btnPlusMinus);

            this->Controls->Add(this->btnPoint);

            this->Controls->Add(this->btnZero);

            this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle;

            this->Margin = System::Windows::Forms::Padding(3, 2, 3, 2);

            this->MaximizeBox = false;

            this->MaximumSize = System::Drawing::Size(341, 381);

            this->MinimumSize = System::Drawing::Size(341, 381);

            this->Name = L"FFirst";

            this->RightToLeft = System::Windows::Forms::RightToLeft::No;

            this->Text = L"Calc";

            this->Load += gcnew System::EventHandler(this, &FFirst::FFirst_Load);

            this->ResumeLayout(false);

            this->PerformLayout();

 

        }

        double firstNum, secondNum, result;

        String^ strResult;

        String^ charOP;

        bool wasEqual = false;

        bool wasOperation = false;

        bool toClear = false;

        bool doubleOperation = false;

        bool wasNotNum = true;

        bool sqrtResult = false;

#pragma endregion

    public: System::Void Calculate() {

        if (charOP == "+") {

            result = firstNum + secondNum;

        }

        else if (charOP == "-") {

            result = firstNum - secondNum;

        }

        else if (charOP == "*") {

            result = firstNum * secondNum;

        }

        else if (charOP == "/") {

            if (secondNum == 0) {

                this->txtPoleVvoda->Text = "На ноль делить нельзя!";

                toClear = true;

                return;

            }

            else {

                result = firstNum / secondNum;

            }

        }

        firstNum = result;

        this->txtPoleVvoda->Text = Convert::ToString(result);

    }

    public: System::Void CalculateSqrt() {

        if (charOP == "+") {

            result = firstNum + sqrt(secondNum);

        }

        else if (charOP == "-") {

            result = firstNum - sqrt(secondNum);

        }

        else if (charOP == "*") {

            result = firstNum * sqrt(secondNum);

        }

        else if (charOP == "/") {

            if (secondNum == 0) {

                this->txtPoleVvoda->Text = "На ноль делить нельзя!";

                toClear = true;

                return;

            }

            else if (secondNum < 0) {

                this->txtPoleVvoda->Text = "Нет корня от числа!";

                toClear = true;

                return;

            }

            else {

                result = firstNum / sqrt(secondNum);

            }

        }

        firstNum = result;

        this->txtPoleVvoda->Text = Convert::ToString(result);

    }

    public: System::Void Percent() {

        txtPoleVvoda->Text = Convert::ToString(firstNum / 100 * secondNum);

    }

 

    private: System::Void Numbers(System::Object^ sender, System::EventArgs^ e) {

        Button^ numb = safe_cast<Button^>(sender);

 

        if (txtPoleVvoda->Text == "0" || txtPoleVvoda->Text == "-0") {

            if (txtPoleVvoda->Text->Contains("-")) {

                txtPoleVvoda->Text = txtPoleVvoda->Text->Remove(1, 1) + numb->Text;

            }

            else {

                txtPoleVvoda->Text = numb->Text;

            }

        }

        else if (toClear) {

            txtPoleVvoda->Text = numb->Text;

            toClear = false;

        }

        else {

            txtPoleVvoda->Text = txtPoleVvoda->Text + numb->Text;

        }

        doubleOperation = false;

        wasEqual = false;

        wasNotNum = false;

    }

 

    private: System::Void arifmOperations(System::Object^ sender, System::EventArgs^ e) {

        Button^ Aop = safe_cast<Button^>(sender);

        if (doubleOperation || wasNotNum) {

            charOP = Aop->Text;

            if (charOP == "-" && txtPoleVvoda->Text->Contains("-")) {

                txtPoleVvoda->Text = txtPoleVvoda->Text->Remove(0, 1);

            }

            return;

        }

        else {

            if (!wasOperation) {

                firstNum = Convert::ToDouble(txtPoleVvoda->Text);

                charOP = Aop->Text;

                wasOperation = true;

                doubleOperation = true;

                toClear = true;

            }

            else if (wasOperation) {

                secondNum = Convert::ToDouble(txtPoleVvoda->Text);

                if (sqrtResult) {

                    CalculateSqrt();

                    sqrtResult = false;

                }

                else {

                    Calculate();

                }

                charOP = Aop->Text;

                doubleOperation = true;

                toClear = true;

            }

            if (charOP == "-" && txtPoleVvoda->Text->Contains("-")) {

                txtPoleVvoda->Text = txtPoleVvoda->Text->Remove(0, 1);

            }

        }

        wasEqual = false;

    }

 

    private: System::Void btnC_Click(System::Object^ sender, System::EventArgs^ e) {

        txtPoleVvoda->Text = "0";

        wasOperation = false;

        firstNum = NULL;

        secondNum = NULL;

        doubleOperation = false;

        wasEqual = false;

        toClear = false;

        sqrtResult = false;

        wasNotNum = true;

 

    }

    private: System::Void btnCE_Click(System::Object^ sender, System::EventArgs^ e) {

        txtPoleVvoda->Text = "0";

        wasOperation = true;

        secondNum = NULL;

        sqrtResult = false;

    }

    private: System::Void btnPoint_Click(System::Object^ sender, System::EventArgs^ e) {

        if (toClear) {

            txtPoleVvoda->Text = "";

            toClear = false;

        }

        if (!txtPoleVvoda->Text->Contains(","))

        {

            txtPoleVvoda->Text = txtPoleVvoda->Text + ",";

        }

    }

    private: System::Void btnBackspace_Click(System::Object^ sender, System::EventArgs^ e) {

        if (txtPoleVvoda->Text->Length > 0) {

            if (txtPoleVvoda->Text->Length == 1)

            {

                txtPoleVvoda->Text = "0";

                return;

            }

            txtPoleVvoda->Text = txtPoleVvoda->Text->Remove(txtPoleVvoda->Text->Length - 1, 1);

        }

        wasOperation = false;

        toClear = false;

    }

    private: System::Void btnEqually_Click(System::Object^ sender, System::EventArgs^ e) {

        if (!wasEqual) {

            if (!txtPoleVvoda->Text->Contains("%")) {

                secondNum = Convert::ToDouble(txtPoleVvoda->Text);

            }

            if (sqrtResult) {

                CalculateSqrt();

                sqrtResult = false;

            }

            else {

                Calculate();

            }

            wasOperation = false;

            wasEqual = true;

        }

        else {

            if (sqrtResult) {

                CalculateSqrt();

                sqrtResult = false;

            }

            else {

                Calculate();

            }

            wasEqual = true;

        }

    }

    private: System::Void btnPlusMinus_Click(System::Object^ sender, System::EventArgs^ e) {

        if (txtPoleVvoda->Text->Contains("-")) {

            txtPoleVvoda->Text = txtPoleVvoda->Text->Remove(0, 1);

        }

        else

        {

            txtPoleVvoda->Text = "-" + txtPoleVvoda->Text;

        }

 

    }

    private: System::Void txtPoleVvoda_TextChanged(System::Object^ sender, System::EventArgs^ e) {

        if (txtPoleVvoda->Text == "") {

            txtPoleVvoda->Text = "0";

        }

    }

    private: System::Void btnSqrt_Click(System::Object^ sender, System::EventArgs^ e) {

 

        if (txtPoleVvoda->Text->Contains("-")) {

            txtPoleVvoda->Text = "Нет корня от числа!";

            toClear = true;

        }

        else {

            double a = sqrt(Convert::ToDouble(txtPoleVvoda->Text));

            txtPoleVvoda->Text = Convert::ToString(a);

        }

 

    }

    private: System::Void btnPercent_Click(System::Object^ sender, System::EventArgs^ e) {

        if (firstNum == NULL) {

            return;

        }

        if (!txtPoleVvoda->Text->Contains("%")) {

            secondNum = Convert::ToDouble(txtPoleVvoda->Text);

            Percent();

        }

    }

    private: System::Void btnInverse_Click(System::Object^ sender, System::EventArgs^ e) {

        double a = Convert::ToDouble(txtPoleVvoda->Text);

        if (a == 0) {

            txtPoleVvoda->Text = "На ноль делить нельзя!";

            toClear = true;

        }

        else {

            a = 1 / a;

            txtPoleVvoda->Text = Convert::ToString(a);

        }

        toClear = true;

    }

    private: System::Void FFirst_Load(System::Object^ sender, System::EventArgs^ e) {

    }

};

}