Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- namespace Cw2 {
- using namespace System;
- using namespace System::ComponentModel;
- using namespace System::Collections;
- using namespace System::Windows::Forms;
- using namespace System::Data;
- using namespace System::Drawing;
- const int RS=10; //rozmiar stosu
- int stos[RS]; // lub wchar_t stos[RS]; // stos
- int js=0; //lub int js=-1; // indeks stosu
- /// <summary>
- /// Summary for MyForm
- /// </summary>
- public ref class MyForm : public System::Windows::Forms::Form
- {
- public:
- MyForm(void)
- {
- InitializeComponent();
- //
- //TODO: Add the constructor code here
- //
- }
- protected:
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- ~MyForm()
- {
- if (components)
- {
- delete components;
- }
- }
- private: System::Windows::Forms::ListBox^ listBox1;
- protected:
- private: System::Windows::Forms::NumericUpDown^ numericUpDown1;
- private: System::Windows::Forms::StatusBar^ statusBar1;
- private: System::Windows::Forms::Button^ buttonZdejmij;
- private: System::Windows::Forms::Button^ buttonDodaj;
- private: System::Windows::Forms::NumericUpDown^ numericUpDown2;
- private:
- /// <summary>
- /// Required designer variable.
- /// </summary>
- System::ComponentModel::Container ^components;
- #pragma region Windows Form Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- void InitializeComponent(void)
- {
- this->listBox1 = (gcnew System::Windows::Forms::ListBox());
- this->numericUpDown1 = (gcnew System::Windows::Forms::NumericUpDown());
- this->statusBar1 = (gcnew System::Windows::Forms::StatusBar());
- this->buttonZdejmij = (gcnew System::Windows::Forms::Button());
- this->buttonDodaj = (gcnew System::Windows::Forms::Button());
- this->numericUpDown2 = (gcnew System::Windows::Forms::NumericUpDown());
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->numericUpDown1))->BeginInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->numericUpDown2))->BeginInit();
- this->SuspendLayout();
- //
- // listBox1
- //
- this->listBox1->FormattingEnabled = true;
- this->listBox1->Location = System::Drawing::Point(12, 15);
- this->listBox1->Name = L"listBox1";
- this->listBox1->Size = System::Drawing::Size(279, 95);
- this->listBox1->TabIndex = 0;
- //
- // numericUpDown1
- //
- this->numericUpDown1->Location = System::Drawing::Point(12, 126);
- this->numericUpDown1->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) {100, 0, 0, System::Int32::MinValue});
- this->numericUpDown1->Name = L"numericUpDown1";
- this->numericUpDown1->Size = System::Drawing::Size(120, 20);
- this->numericUpDown1->TabIndex = 1;
- this->numericUpDown1->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 0});
- //
- // statusBar1
- //
- this->statusBar1->Location = System::Drawing::Point(0, 239);
- this->statusBar1->Name = L"statusBar1";
- this->statusBar1->Size = System::Drawing::Size(313, 22);
- this->statusBar1->TabIndex = 2;
- this->statusBar1->Text = L"statusBar1";
- //
- // buttonZdejmij
- //
- this->buttonZdejmij->Location = System::Drawing::Point(171, 152);
- this->buttonZdejmij->Name = L"buttonZdejmij";
- this->buttonZdejmij->Size = System::Drawing::Size(75, 23);
- this->buttonZdejmij->TabIndex = 3;
- this->buttonZdejmij->Text = L"Zdejmij";
- this->buttonZdejmij->UseVisualStyleBackColor = true;
- this->buttonZdejmij->Click += gcnew System::EventHandler(this, &MyForm::buttonZdejmij_Click);
- //
- // buttonDodaj
- //
- this->buttonDodaj->Location = System::Drawing::Point(12, 152);
- this->buttonDodaj->Name = L"buttonDodaj";
- this->buttonDodaj->Size = System::Drawing::Size(75, 23);
- this->buttonDodaj->TabIndex = 4;
- this->buttonDodaj->Text = L"Dodaj";
- this->buttonDodaj->UseVisualStyleBackColor = true;
- this->buttonDodaj->Click += gcnew System::EventHandler(this, &MyForm::buttonDodaj_Click);
- //
- // numericUpDown2
- //
- this->numericUpDown2->Location = System::Drawing::Point(171, 126);
- this->numericUpDown2->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) {100, 0, 0, System::Int32::MinValue});
- this->numericUpDown2->Name = L"numericUpDown2";
- this->numericUpDown2->Size = System::Drawing::Size(120, 20);
- this->numericUpDown2->TabIndex = 5;
- //
- // MyForm
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(313, 261);
- this->Controls->Add(this->numericUpDown2);
- this->Controls->Add(this->buttonDodaj);
- this->Controls->Add(this->buttonZdejmij);
- this->Controls->Add(this->statusBar1);
- this->Controls->Add(this->numericUpDown1);
- this->Controls->Add(this->listBox1);
- this->Name = L"MyForm";
- this->Text = L"MyForm";
- this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->numericUpDown1))->EndInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->numericUpDown2))->EndInit();
- this->ResumeLayout(false);
- }
- #pragma endregion
- private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e)
- {
- }
- private: System::Void buttonDodaj_Click(System::Object^ sender, System::EventArgs^ e)
- {
- if (js>=RS) //lub if (js>=RS-1)
- {
- statusBar1->Text = "Stos jest zapełniony";
- }
- else
- {
- // instrukcje odkładania elementu na stos
- stos[js++]=System::Decimal::ToInt32(numericUpDown1->Value);
- listBox1->Items->Clear();
- for (int i=0;i<=js;i++) listBox1->Items->Add(stos[i]);
- listBox1->SelectedIndex = js;
- }
- }
- private: System::Void buttonZdejmij_Click(System::Object^ sender, System::EventArgs^ e)
- {
- if (js==0) // lub if (js<0)
- {
- statusBar1->Text = "Stos jest pusty";
- }
- else
- {
- // instrukcje zdejmowania elementu ze stosu
- numericUpDown2->Value=stos[--js];
- listBox1->Items->Clear();
- for (int i=0;i<=js;i++) listBox1->Items->Add(stos[i]);
- listBox1->SelectedIndex = js;
- }
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement