Advertisement
peterzig

zadanie C++ CLR

Apr 29th, 2020
564
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.79 KB | None | 0 0
  1. #pragma once
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <cmath>
  5.  
  6. namespace CppCLRWinformsProjekt {
  7.  
  8.     using namespace System;
  9.     using namespace System::ComponentModel;
  10.     using namespace System::Collections;
  11.     using namespace System::Windows::Forms;
  12.     using namespace System::Data;
  13.     using namespace System::Drawing;
  14.  
  15.     public ref class Form1 : public System::Windows::Forms::Form
  16.     {
  17.     public:
  18.         Form1(void)
  19.         {
  20.             InitializeComponent();
  21.         }
  22.         int low = 0;
  23.         int high = 0;
  24.         int x;
  25.         int value;
  26.     private: System::Windows::Forms::Button^ button3;
  27.     public:
  28.        
  29.  
  30.     protected:
  31.  
  32.         ~Form1()
  33.         {
  34.             if (components)
  35.             {
  36.                 delete components;
  37.             }
  38.         }
  39.     private: System::Windows::Forms::TextBox^ textBox1;
  40.     protected:
  41.     private: System::Windows::Forms::TextBox^ textBox2;
  42.     private: System::Windows::Forms::Label^ label1;
  43.     private: System::Windows::Forms::Button^ button1;
  44.     private: System::Windows::Forms::Label^ label2;
  45.     private: System::Windows::Forms::TextBox^ textBox3;
  46.     private: System::Windows::Forms::Button^ button2;
  47.     private: System::Windows::Forms::Label^ label3;
  48.     private: System::Windows::Forms::Label^ label4;
  49.  
  50.     protected:
  51.  
  52.     private:
  53.  
  54.         System::ComponentModel::Container ^components;
  55.  
  56. #pragma region Windows Form Designer generated code
  57.  
  58.         void InitializeComponent(void)
  59.         {
  60.             this->textBox1 = (gcnew System::Windows::Forms::TextBox());
  61.             this->textBox2 = (gcnew System::Windows::Forms::TextBox());
  62.             this->label1 = (gcnew System::Windows::Forms::Label());
  63.             this->button1 = (gcnew System::Windows::Forms::Button());
  64.             this->label2 = (gcnew System::Windows::Forms::Label());
  65.             this->textBox3 = (gcnew System::Windows::Forms::TextBox());
  66.             this->button2 = (gcnew System::Windows::Forms::Button());
  67.             this->label3 = (gcnew System::Windows::Forms::Label());
  68.             this->label4 = (gcnew System::Windows::Forms::Label());
  69.             this->button3 = (gcnew System::Windows::Forms::Button());
  70.             this->SuspendLayout();
  71.             //
  72.             // textBox1
  73.             //
  74.             this->textBox1->Location = System::Drawing::Point(20, 63);
  75.             this->textBox1->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  76.             this->textBox1->Name = L"textBox1";
  77.             this->textBox1->Size = System::Drawing::Size(67, 26);
  78.             this->textBox1->TabIndex = 0;
  79.             this->textBox1->TextChanged += gcnew System::EventHandler(this, &Form1::textBox1_TextChanged);
  80.             //
  81.             // textBox2
  82.             //
  83.             this->textBox2->Location = System::Drawing::Point(98, 63);
  84.             this->textBox2->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  85.             this->textBox2->Name = L"textBox2";
  86.             this->textBox2->Size = System::Drawing::Size(64, 26);
  87.             this->textBox2->TabIndex = 1;
  88.             this->textBox2->TextChanged += gcnew System::EventHandler(this, &Form1::textBox2_TextChanged);
  89.             //
  90.             // label1
  91.             //
  92.             this->label1->AutoSize = true;
  93.             this->label1->Location = System::Drawing::Point(20, 34);
  94.             this->label1->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
  95.             this->label1->Name = L"label1";
  96.             this->label1->Size = System::Drawing::Size(174, 20);
  97.             this->label1->TabIndex = 2;
  98.             this->label1->Text = L"Podaj 2 liczby całkowite";
  99.             //
  100.             // button1
  101.             //
  102.             this->button1->Location = System::Drawing::Point(172, 63);
  103.             this->button1->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  104.             this->button1->Name = L"button1";
  105.             this->button1->Size = System::Drawing::Size(112, 35);
  106.             this->button1->TabIndex = 3;
  107.             this->button1->Text = L"Oblicz!";
  108.             this->button1->UseVisualStyleBackColor = true;
  109.             this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
  110.             //
  111.             // label2
  112.             //
  113.             this->label2->AutoSize = true;
  114.             this->label2->Location = System::Drawing::Point(20, 162);
  115.             this->label2->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
  116.             this->label2->Name = L"label2";
  117.             this->label2->Size = System::Drawing::Size(60, 20);
  118.             this->label2->TabIndex = 4;
  119.             this->label2->Text = L"Podaj x";
  120.             //
  121.             // textBox3
  122.             //
  123.             this->textBox3->Location = System::Drawing::Point(20, 186);
  124.             this->textBox3->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  125.             this->textBox3->Name = L"textBox3";
  126.             this->textBox3->Size = System::Drawing::Size(67, 26);
  127.             this->textBox3->TabIndex = 5;
  128.             this->textBox3->TextChanged += gcnew System::EventHandler(this, &Form1::textBox3_TextChanged);
  129.             //
  130.             // button2
  131.             //
  132.             this->button2->Location = System::Drawing::Point(111, 183);
  133.             this->button2->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  134.             this->button2->Name = L"button2";
  135.             this->button2->Size = System::Drawing::Size(112, 35);
  136.             this->button2->TabIndex = 6;
  137.             this->button2->Text = L"Oblicz!";
  138.             this->button2->UseVisualStyleBackColor = true;
  139.             this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
  140.             //
  141.             // label3
  142.             //
  143.             this->label3->AutoSize = true;
  144.             this->label3->Location = System::Drawing::Point(20, 112);
  145.             this->label3->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
  146.             this->label3->Name = L"label3";
  147.             this->label3->Size = System::Drawing::Size(59, 20);
  148.             this->label3->TabIndex = 7;
  149.             this->label3->Text = L"Wynik: ";
  150.             //
  151.             // label4
  152.             //
  153.             this->label4->AutoSize = true;
  154.             this->label4->Location = System::Drawing::Point(15, 243);
  155.             this->label4->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
  156.             this->label4->Name = L"label4";
  157.             this->label4->Size = System::Drawing::Size(59, 20);
  158.             this->label4->TabIndex = 8;
  159.             this->label4->Text = L"Wynik: ";
  160.             //
  161.             // button3
  162.             //
  163.             this->button3->Location = System::Drawing::Point(292, 63);
  164.             this->button3->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  165.             this->button3->Name = L"button3";
  166.             this->button3->Size = System::Drawing::Size(112, 35);
  167.             this->button3->TabIndex = 9;
  168.             this->button3->Text = L"Wyczyść";
  169.             this->button3->UseVisualStyleBackColor = true;
  170.             this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
  171.             //
  172.             // Form1
  173.             //
  174.             this->AutoScaleDimensions = System::Drawing::SizeF(9, 20);
  175.             this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  176.             this->ClientSize = System::Drawing::Size(489, 374);
  177.             this->Controls->Add(this->button3);
  178.             this->Controls->Add(this->label4);
  179.             this->Controls->Add(this->label3);
  180.             this->Controls->Add(this->button2);
  181.             this->Controls->Add(this->textBox3);
  182.             this->Controls->Add(this->label2);
  183.             this->Controls->Add(this->button1);
  184.             this->Controls->Add(this->label1);
  185.             this->Controls->Add(this->textBox2);
  186.             this->Controls->Add(this->textBox1);
  187.             this->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  188.             this->Name = L"Form1";
  189.             this->Text = L"made by Zuzanna Prościak";
  190.             this->ResumeLayout(false);
  191.             this->PerformLayout();
  192.  
  193.         }
  194. #pragma endregion
  195.     private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) {
  196.     }
  197.     private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
  198.         low = System::Int32::Parse(textBox1->Text);
  199.     }
  200.     private: System::Void textBox2_TextChanged(System::Object^ sender, System::EventArgs^ e) {
  201.         high = System::Int32::Parse(textBox2->Text);
  202.     }
  203.  
  204.  
  205. private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
  206.     if (x <= 0) {
  207.         value = x / ((2 * x) + 1);
  208.     }
  209.     if (x > 0 || x <= 5) {
  210.         value = ((2 * x) + 1) / (4 * x);
  211.     }
  212.     if (x > 5) {
  213.         value = 5 * (pow(x, 4));
  214.     }
  215.     label4->Text = "Wynik: " + value;
  216. }
  217.     private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
  218.         for (int i = low; i <= high; i++) {
  219.             label3->Text += " " + i;
  220.     }
  221.    
  222. }
  223. private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
  224.     label3->Text = "Wynik: ";
  225. }
  226. private: System::Void textBox3_TextChanged(System::Object^ sender, System::EventArgs^ e) {
  227.     x = System::Int32::Parse(textBox3->Text);
  228.  
  229. }
  230. };
  231. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement