Untitled
beq
c_cpp
2 years ago
4.8 kB
3
Indexable
// MyForm.cpp #include "MyForm.h" using namespace System; using namespace System::Windows::Forms; [STAThread] int main(array<String^>^ args) { Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); test2::MyForm form; Application::Run(% form); } //MyForm.h #pragma once // Функция для вычисления факториала int Factorial(int n) { if (n == 0 || n == 1) { return 1; } else { return n * Factorial(n - 1); } } namespace test2 { 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 MyForm : public System::Windows::Forms::Form { public: MyForm(void) { InitializeComponent(); // //TODO: добавьте код конструктора // } protected: /// <summary> /// Освободить все используемые ресурсы. /// </summary> ~MyForm() { if (components) { delete components; } } private: System::Windows::Forms::Button^ button1; private: System::Windows::Forms::NumericUpDown^ numericUpDown1; private: System::Windows::Forms::TextBox^ textBox1; private: System::Windows::Forms::Label^ label1; private: System::Windows::Forms::Label^ label2; protected: private: /// <summary> /// Обязательная переменная конструктора. /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// Требуемый метод для поддержки конструктора — не изменяйте /// содержимое этого метода с помощью редактора кода. /// </summary> void InitializeComponent(void) { this->button1 = (gcnew System::Windows::Forms::Button()); this->numericUpDown1 = (gcnew System::Windows::Forms::NumericUpDown()); this->textBox1 = (gcnew System::Windows::Forms::TextBox()); this->label1 = (gcnew System::Windows::Forms::Label()); this->label2 = (gcnew System::Windows::Forms::Label()); (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown1))->BeginInit(); this->SuspendLayout(); // // button1 // this->button1->Location = System::Drawing::Point(23, 184); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(230, 55); this->button1->TabIndex = 0; this->button1->Text = L"button1"; this->button1->UseVisualStyleBackColor = true; this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click); // // numericUpDown1 // this->numericUpDown1->Location = System::Drawing::Point(23, 144); this->numericUpDown1->Name = L"numericUpDown1"; this->numericUpDown1->Size = System::Drawing::Size(230, 20); this->numericUpDown1->TabIndex = 1; // // textBox1 // this->textBox1->Location = System::Drawing::Point(27, 45); this->textBox1->Name = L"textBox1"; this->textBox1->Size = System::Drawing::Size(225, 20); this->textBox1->TabIndex = 2; // // label1 // this->label1->AutoSize = true; this->label1->Location = System::Drawing::Point(129, 128); this->label1->Name = L"label1"; this->label1->Size = System::Drawing::Size(15, 13); this->label1->TabIndex = 3; this->label1->Text = L"N"; // // label2 // this->label2->AutoSize = true; this->label2->Location = System::Drawing::Point(76, 29); this->label2->Name = L"label2"; this->label2->Size = System::Drawing::Size(128, 13); this->label2->TabIndex = 4; this->label2->Text = L" ЧИСЛО - ФАКТОРИАЛ"; // // MyForm // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(284, 261); this->Controls->Add(this->label2); this->Controls->Add(this->label1); this->Controls->Add(this->textBox1); this->Controls->Add(this->numericUpDown1); this->Controls->Add(this->button1); this->Name = L"MyForm"; this->Text = L"MyForm"; (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown1))->EndInit(); this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { int n = Decimal::ToInt32(numericUpDown1->Value); int result = Factorial(n); textBox1->Text = "Факториал " + n.ToString() + " = " + result.ToString(); } }; }
Editor is loading...
Leave a Comment