Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- namespace Informatika2ND {
- 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>
- /// 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::TextBox^ textBox1;
- protected:
- private: System::Windows::Forms::Label^ label1;
- private: System::Windows::Forms::Label^ label2;
- private: System::Windows::Forms::Label^ label3;
- private: System::Windows::Forms::Label^ label4;
- private: System::Windows::Forms::Label^ label5;
- private: System::Windows::Forms::Button^ button1;
- 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->textBox1 = (gcnew System::Windows::Forms::TextBox());
- this->label1 = (gcnew System::Windows::Forms::Label());
- this->label2 = (gcnew System::Windows::Forms::Label());
- this->label3 = (gcnew System::Windows::Forms::Label());
- this->label4 = (gcnew System::Windows::Forms::Label());
- this->label5 = (gcnew System::Windows::Forms::Label());
- this->button1 = (gcnew System::Windows::Forms::Button());
- this->SuspendLayout();
- //
- // textBox1
- //
- this->textBox1->Location = System::Drawing::Point(206, 28);
- this->textBox1->Name = L"textBox1";
- this->textBox1->Size = System::Drawing::Size(100, 20);
- this->textBox1->TabIndex = 0;
- //
- // label1
- //
- this->label1->AutoSize = true;
- this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 15.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->label1->Location = System::Drawing::Point(12, 23);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(188, 25);
- this->label1->TabIndex = 1;
- this->label1->Text = L"Sveikasis skaicius";
- //
- // label2
- //
- this->label2->AutoSize = true;
- this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 15.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->label2->Location = System::Drawing::Point(131, 84);
- this->label2->Name = L"label2";
- this->label2->Size = System::Drawing::Size(175, 25);
- this->label2->TabIndex = 5;
- this->label2->Text = L"Skaicius turi tiek:";
- //
- // label3
- //
- this->label3->AutoSize = true;
- this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->label3->Location = System::Drawing::Point(2, 155);
- this->label3->Name = L"label3";
- this->label3->Size = System::Drawing::Size(76, 18);
- this->label3->TabIndex = 6;
- this->label3->Text = L"Vienetuku:";
- //
- // label4
- //
- this->label4->AutoSize = true;
- this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->label4->Location = System::Drawing::Point(233, 155);
- this->label4->Name = L"label4";
- this->label4->Size = System::Drawing::Size(73, 18);
- this->label4->TabIndex = 7;
- this->label4->Text = L"Trejetuku:";
- //
- // label5
- //
- this->label5->AutoSize = true;
- this->label5->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->label5->Location = System::Drawing::Point(100, 212);
- this->label5->Name = L"label5";
- this->label5->Size = System::Drawing::Size(82, 18);
- this->label5->TabIndex = 8;
- this->label5->Text = L"Penketuku:";
- //
- // button1
- //
- this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(0)));
- this->button1->Location = System::Drawing::Point(136, 58);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(145, 23);
- this->button1->TabIndex = 9;
- this->button1->Text = L"Apskaiciuoti";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
- //
- // MyForm
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(435, 257);
- this->Controls->Add(this->button1);
- this->Controls->Add(this->label5);
- this->Controls->Add(this->label4);
- this->Controls->Add(this->label3);
- this->Controls->Add(this->label2);
- this->Controls->Add(this->label1);
- this->Controls->Add(this->textBox1);
- this->Name = L"MyForm";
- this->Text = L"Namu darbas 2";
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) // Kai paspaudi mygtuka atlieka visus skaiciavimus
- {
- int skaicius;
- skaicius = int::Parse(textBox1->Text); //Paema ka is textboxo skaiciu ir pakeicia int skaicius reiksme i ta.
- // iskvieciu is funkcijos skaicius 1, 3, 5.
- label3->Text = "Vienetukai: " + sprendimas(skaicius, 1).ToString();
- label4->Text = "Trejetukai: " + sprendimas(skaicius, 3).ToString();
- label5->Text = "Penketukai: " + sprendimas(skaicius, 5).ToString();
- }
- int sprendimas(int skaicius, int ieskotiSkc)
- {
- int kiekis = 0;
- while (skaicius != 0)
- {
- // pasiema paskutini skc.
- skaicius %= 10;
- if (skaicius == ieskotiSkc)
- kiekis++;
- skaicius /= 10;
- }
- return kiekis;
- }
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement