#pragma once #include #include #include #include #include #include #include namespace lb { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace msclr::interop; using namespace std; /// /// Сводка для MyForm /// public ref class MyForm : public System::Windows::Forms::Form { public: MyForm(void) { InitializeComponent(); // //TODO: добавьте код конструктора // } protected: /// /// Освободить все используемые ресурсы. /// ~MyForm() { if (components) { delete components; } } private: System::Windows::Forms::Button^ button1; protected: private: System::Windows::Forms::TextBox^ textBox1; private: System::Windows::Forms::TextBox^ textBox2; private: System::Windows::Forms::Label^ label1; private: System::Windows::Forms::Label^ label2; private: /// /// Обязательная переменная конструктора. /// System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// /// Требуемый метод для поддержки конструктора — не изменяйте /// содержимое этого метода с помощью редактора кода. /// void InitializeComponent(void) { this->button1 = (gcnew System::Windows::Forms::Button()); this->textBox1 = (gcnew System::Windows::Forms::TextBox()); this->textBox2 = (gcnew System::Windows::Forms::TextBox()); this->label1 = (gcnew System::Windows::Forms::Label()); this->label2 = (gcnew System::Windows::Forms::Label()); this->SuspendLayout(); // // button1 // this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 20)); this->button1->ForeColor = System::Drawing::SystemColors::HotTrack; this->button1->Location = System::Drawing::Point(276, 299); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(273, 94); this->button1->TabIndex = 0; this->button1->Text = L"Вывести слова"; this->button1->UseVisualStyleBackColor = true; this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click); // // textBox1 // this->textBox1->Location = System::Drawing::Point(206, 225); this->textBox1->Name = L"textBox1"; this->textBox1->Size = System::Drawing::Size(406, 20); this->textBox1->TabIndex = 1; // // textBox2 // this->textBox2->Location = System::Drawing::Point(206, 139); this->textBox2->Name = L"textBox2"; this->textBox2->Size = System::Drawing::Size(406, 20); this->textBox2->TabIndex = 2; // // label1 // this->label1->AutoSize = true; this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 20)); this->label1->ForeColor = System::Drawing::SystemColors::MenuHighlight; this->label1->Location = System::Drawing::Point(212, 94); this->label1->Name = L"label1"; this->label1->Size = System::Drawing::Size(391, 31); this->label1->TabIndex = 3; this->label1->Text = L"Введите слова через запятую"; this->label1->Click += gcnew System::EventHandler(this, &MyForm::label1_Click); // // label2 // this->label2->AutoSize = true; this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 20)); this->label2->ForeColor = System::Drawing::SystemColors::HotTrack; this->label2->Location = System::Drawing::Point(169, 179); this->label2->Name = L"label2"; this->label2->Size = System::Drawing::Size(487, 31); this->label2->TabIndex = 4; this->label2->Text = L"Слова, заканчивающиеся на букву W"; // // MyForm // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(816, 549); this->Controls->Add(this->label2); this->Controls->Add(this->label1); this->Controls->Add(this->textBox2); this->Controls->Add(this->textBox1); this->Controls->Add(this->button1); this->Name = L"Поиск слов с буквой W"; this->Text = L"Поиск слов с буквой W"; this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { String^ str = textBox2->Text; string s1 = ""; string s = marshal_as(str); s = s + ','; int k = 0, n = 0, j = 0, p = 0; for (int i = 0; i < s.length(); i++) { if (s[i] == ',') { if (i > 0 && s[i - 1] == 'w') for (k; k <= i; k++) { s1 += s[k]; n++; } k = i + 1; } } if (n == 0) textBox1->Text = "Нет слов, заканчивающихся на букву w"; else { s1.erase(s1.end() - 1); String^ str1 = marshal_as(s1); textBox1->Text = str1; } } private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) { } }; }