Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <stdlib.h>
- #include <math.h>
- #include <cmath>
- namespace CppCLRWinformsProjekt {
- using namespace System;
- using namespace System::ComponentModel;
- using namespace System::Collections;
- using namespace System::Windows::Forms;
- using namespace System::Data;
- using namespace System::Drawing;
- public ref class Form1 : public System::Windows::Forms::Form
- {
- public:
- Form1(void)
- {
- InitializeComponent();
- }
- int low = 0;
- int high = 0;
- int x;
- int value;
- private: System::Windows::Forms::Button^ button3;
- public:
- protected:
- ~Form1()
- {
- if (components)
- {
- delete components;
- }
- }
- private: System::Windows::Forms::TextBox^ textBox1;
- protected:
- private: System::Windows::Forms::TextBox^ textBox2;
- private: System::Windows::Forms::Label^ label1;
- private: System::Windows::Forms::Button^ button1;
- private: System::Windows::Forms::Label^ label2;
- private: System::Windows::Forms::TextBox^ textBox3;
- private: System::Windows::Forms::Button^ button2;
- private: System::Windows::Forms::Label^ label3;
- private: System::Windows::Forms::Label^ label4;
- protected:
- private:
- System::ComponentModel::Container ^components;
- #pragma region Windows Form Designer generated code
- void InitializeComponent(void)
- {
- this->textBox1 = (gcnew System::Windows::Forms::TextBox());
- this->textBox2 = (gcnew System::Windows::Forms::TextBox());
- this->label1 = (gcnew System::Windows::Forms::Label());
- this->button1 = (gcnew System::Windows::Forms::Button());
- this->label2 = (gcnew System::Windows::Forms::Label());
- this->textBox3 = (gcnew System::Windows::Forms::TextBox());
- this->button2 = (gcnew System::Windows::Forms::Button());
- this->label3 = (gcnew System::Windows::Forms::Label());
- this->label4 = (gcnew System::Windows::Forms::Label());
- this->button3 = (gcnew System::Windows::Forms::Button());
- this->SuspendLayout();
- //
- // textBox1
- //
- this->textBox1->Location = System::Drawing::Point(20, 63);
- this->textBox1->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->textBox1->Name = L"textBox1";
- this->textBox1->Size = System::Drawing::Size(67, 26);
- this->textBox1->TabIndex = 0;
- this->textBox1->TextChanged += gcnew System::EventHandler(this, &Form1::textBox1_TextChanged);
- //
- // textBox2
- //
- this->textBox2->Location = System::Drawing::Point(98, 63);
- this->textBox2->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->textBox2->Name = L"textBox2";
- this->textBox2->Size = System::Drawing::Size(64, 26);
- this->textBox2->TabIndex = 1;
- this->textBox2->TextChanged += gcnew System::EventHandler(this, &Form1::textBox2_TextChanged);
- //
- // label1
- //
- this->label1->AutoSize = true;
- this->label1->Location = System::Drawing::Point(20, 34);
- this->label1->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(174, 20);
- this->label1->TabIndex = 2;
- this->label1->Text = L"Podaj 2 liczby całkowite";
- //
- // button1
- //
- this->button1->Location = System::Drawing::Point(172, 63);
- this->button1->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(112, 35);
- this->button1->TabIndex = 3;
- this->button1->Text = L"Oblicz!";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
- //
- // label2
- //
- this->label2->AutoSize = true;
- this->label2->Location = System::Drawing::Point(20, 162);
- this->label2->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
- this->label2->Name = L"label2";
- this->label2->Size = System::Drawing::Size(60, 20);
- this->label2->TabIndex = 4;
- this->label2->Text = L"Podaj x";
- //
- // textBox3
- //
- this->textBox3->Location = System::Drawing::Point(20, 186);
- this->textBox3->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->textBox3->Name = L"textBox3";
- this->textBox3->Size = System::Drawing::Size(67, 26);
- this->textBox3->TabIndex = 5;
- this->textBox3->TextChanged += gcnew System::EventHandler(this, &Form1::textBox3_TextChanged);
- //
- // button2
- //
- this->button2->Location = System::Drawing::Point(111, 183);
- this->button2->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->button2->Name = L"button2";
- this->button2->Size = System::Drawing::Size(112, 35);
- this->button2->TabIndex = 6;
- this->button2->Text = L"Oblicz!";
- this->button2->UseVisualStyleBackColor = true;
- this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
- //
- // label3
- //
- this->label3->AutoSize = true;
- this->label3->Location = System::Drawing::Point(20, 112);
- this->label3->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
- this->label3->Name = L"label3";
- this->label3->Size = System::Drawing::Size(59, 20);
- this->label3->TabIndex = 7;
- this->label3->Text = L"Wynik: ";
- //
- // label4
- //
- this->label4->AutoSize = true;
- this->label4->Location = System::Drawing::Point(15, 243);
- this->label4->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
- this->label4->Name = L"label4";
- this->label4->Size = System::Drawing::Size(59, 20);
- this->label4->TabIndex = 8;
- this->label4->Text = L"Wynik: ";
- //
- // button3
- //
- this->button3->Location = System::Drawing::Point(292, 63);
- this->button3->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->button3->Name = L"button3";
- this->button3->Size = System::Drawing::Size(112, 35);
- this->button3->TabIndex = 9;
- this->button3->Text = L"Wyczyść";
- this->button3->UseVisualStyleBackColor = true;
- this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
- //
- // Form1
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(9, 20);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(489, 374);
- this->Controls->Add(this->button3);
- this->Controls->Add(this->label4);
- this->Controls->Add(this->label3);
- this->Controls->Add(this->button2);
- this->Controls->Add(this->textBox3);
- this->Controls->Add(this->label2);
- this->Controls->Add(this->button1);
- this->Controls->Add(this->label1);
- this->Controls->Add(this->textBox2);
- this->Controls->Add(this->textBox1);
- this->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->Name = L"Form1";
- this->Text = L"made by Zuzanna Prościak";
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) {
- }
- private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
- low = System::Int32::Parse(textBox1->Text);
- }
- private: System::Void textBox2_TextChanged(System::Object^ sender, System::EventArgs^ e) {
- high = System::Int32::Parse(textBox2->Text);
- }
- private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
- if (x <= 0) {
- value = x / ((2 * x) + 1);
- }
- if (x > 0 || x <= 5) {
- value = ((2 * x) + 1) / (4 * x);
- }
- if (x > 5) {
- value = 5 * (pow(x, 4));
- }
- label4->Text = "Wynik: " + value;
- }
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
- for (int i = low; i <= high; i++) {
- label3->Text += " " + i;
- }
- }
- private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
- label3->Text = "Wynik: ";
- }
- private: System::Void textBox3_TextChanged(System::Object^ sender, System::EventArgs^ e) {
- x = System::Int32::Parse(textBox3->Text);
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement