Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //После namespace:
- void string_split_smart(string str, string razd, string*& result, int& new_count) {
- for (int i = 0; i < str.length(); i++) {
- int l = razd.find(str[i]);
- if (l < 0 || l > razd.length()) {
- result[new_count] = result[new_count] + str[i];
- }
- else {
- if (str[i] == ' ') {
- if (result[new_count] != "") {
- result[++new_count] = "";
- }
- }
- else {
- if (result[new_count] != "") {
- new_count++;
- }
- result[new_count] = str[i];
- result[++new_count] = "";
- }
- }
- }
- }
- //После кода компилятора:
- private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e) {
- }
- //Universe:
- private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
- if (this->textBox1->Text != "")
- {
- u_size = Convert::ToInt64(this->textBox3->Text);
- }
- }
- //And
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
- {
- this->textBox4->Text = " ";
- TSet A(u_size);
- TSet B(u_size);
- for (int i = 0; i < this->textBox1->Text->Split(' ')->Length; i++)
- {
- A.Add(Convert::ToInt32(this->textBox1->Text->Split(' ')[i]));
- }
- for (int i = 0; i < this->textBox2->Text->Split(' ')->Length; i++)
- {
- B.Add(Convert::ToInt32(this->textBox2->Text->Split(' ')[i]));
- }
- string res = (A & B).TSet_to_String();
- string* sos = new string[res.length() / 2 + 2];
- int count = 0;
- string_split_smart(res, " ", sos, count);
- for (int i = 0; i < count+1; i++)
- {
- this->textBox4->Text += Convert::ToString(atoi(sos[i].c_str())) + " ";
- }
- this->textBox2->Text = " ";
- string res2 = B.TSet_to_String();
- string* sos2 = new string[res.length() / 2 + 2];
- int count2 = 0;
- string_split_smart(res2, " ", sos2, count2);
- for (int i = 0; i < count2 + 1; i++)
- {
- this->textBox2->Text += Convert::ToString(atoi(sos2[i].c_str())) + " ";
- }
- this->textBox1->Text = " ";
- string res3 = A.TSet_to_String();
- string* sos3 = new string[res.length() / 2 + 2];
- int count3 = 0;
- string_split_smart(res3, " ", sos3, count3);
- for (int i = 0; i < count3 + 1; i++)
- {
- this->textBox1->Text += Convert::ToString(atoi(sos3[i].c_str())) + " ";
- }
- }
- //Or
- private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)
- {
- this->textBox4->Text = " ";
- TSet A(u_size);
- TSet B(u_size);
- for (int i = 0; i < this->textBox1->Text->Split(' ')->Length; i++)
- {
- A.Add(Convert::ToInt32(this->textBox1->Text->Split(' ')[i]));
- }
- for (int i = 0; i < this->textBox2->Text->Split(' ')->Length; i++)
- {
- B.Add(Convert::ToInt32(this->textBox2->Text->Split(' ')[i]));
- }
- string res = (A | B).TSet_to_String();
- string* sos = new string[res.length() / 2 + 2];
- int count = 0;
- string_split_smart(res, " ", sos, count);
- for (int i = 0; i < count + 1; i++)
- {
- this->textBox4->Text += Convert::ToString(atoi(sos[i].c_str())) + " ";
- }
- this->textBox2->Text = " ";
- string res2 = B.TSet_to_String();
- string* sos2 = new string[res.length() / 2 + 2];
- int count2 = 0;
- string_split_smart(res2, " ", sos2, count2);
- for (int i = 0; i < count2 + 1; i++)
- {
- this->textBox2->Text += Convert::ToString(atoi(sos2[i].c_str())) + " ";
- }
- this->textBox1->Text = " ";
- string res3 = A.TSet_to_String();
- string* sos3 = new string[res.length() / 2 + 2];
- int count3 = 0;
- string_split_smart(res3, " ", sos3, count3);
- for (int i = 0; i < count3 + 1; i++)
- {
- this->textBox1->Text += Convert::ToString(atoi(sos3[i].c_str())) + " ";
- }
- }
- //Complement A
- private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e)
- {
- this->textBox4->Text = " ";
- TSet A(u_size);
- for (int i = 0; i < this->textBox1->Text->Split(' ')->Length; i++)
- {
- A.Add(Convert::ToInt32(this->textBox1->Text->Split(' ')[i]));
- }
- string res = (~A).TSet_to_String();
- string* sos = new string[res.length() / 2 + 2];
- int count = 0;
- string_split_smart(res, " ", sos, count);
- for (int i = 0; i < count + 1; i++)
- {
- this->textBox4->Text += Convert::ToString(atoi(sos[i].c_str())) + " ";
- }
- this->textBox2->Text = " ";
- string res2 = A.TSet_to_String();
- string* sos2 = new string[res.length() / 2 + 2];
- int count2 = 0;
- string_split_smart(res2, " ", sos2, count2);
- for (int i = 0; i < count2 + 1; i++)
- {
- this->textBox1->Text += Convert::ToString(atoi(sos2[i].c_str())) + " ";
- }
- }
- //Complement B
- private: System::Void button8_Click(System::Object^ sender, System::EventArgs^ e)
- {
- this->textBox4->Text = " ";
- TSet B(u_size);
- for (int i = 0; i < this->textBox2->Text->Split(' ')->Length; i++)
- {
- B.Add(Convert::ToInt32(this->textBox2->Text->Split(' ')[i]));
- }
- string res = (~B).TSet_to_String();
- string* sos = new string[res.length() / 2 + 2];
- int count = 0;
- string_split_smart(res, " ", sos, count);
- for (int i = 0; i < count + 1; i++)
- {
- this->textBox4->Text += Convert::ToString(atoi(sos[i].c_str())) + " ";
- }
- this->textBox2->Text = " ";
- string res2 = B.TSet_to_String();
- string* sos2 = new string[res.length() / 2 + 2];
- int count2 = 0;
- string_split_smart(res2, " ", sos2, count2);
- for (int i = 0; i < count2 + 1; i++)
- {
- this->textBox2->Text += Convert::ToString(atoi(sos2[i].c_str())) + " ";
- }
- }
- B.Add(Convert::ToInt32(this->textBox2->Text->Split(' ')[i]));
- }
- string res = (A | B).TSet_to_String();
- string* sos = new string[res.length() / 2 + 2];
- int count = 0;
- string_split_smart(res, " ", sos, count);
- for (int i = 0; i < count + 1; i++)
- {
- this->textBox4->Text += Convert::ToString(atoi(sos[i].c_str())) + " ";
- }
- }
- //Complement A
- private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e)
- {
- this->textBox4->Text = " ";
- TSet A(u_size);
- for (int i = 0; i < this->textBox1->Text->Split(' ')->Length; i++)
- {
- A.Add(Convert::ToInt32(this->textBox1->Text->Split(' ')[i]));
- }
- string res = (~A).TSet_to_String();
- string* sos = new string[res.length() / 2 + 2];
- int count = 0;
- string_split_smart(res, " ", sos, count);
- for (int i = 0; i < count + 1; i++)
- {
- this->textBox4->Text += Convert::ToString(atoi(sos[i].c_str())) + " ";
- }
- }
- //Complement B
- private: System::Void button8_Click(System::Object^ sender, System::EventArgs^ e)
- {
- this->textBox4->Text = " ";
- TSet B(u_size);
- for (int i = 0; i < this->textBox2->Text->Split(' ')->Length; i++)
- {
- B.Add(Convert::ToInt32(this->textBox2->Text->Split(' ')[i]));
- }
- string res = (~B).TSet_to_String();
- string* sos = new string[res.length() / 2 + 2];
- int count = 0;
- string_split_smart(res, " ", sos, count);
- for (int i = 0; i < count + 1; i++)
- {
- this->textBox4->Text += Convert::ToString(atoi(sos[i].c_str())) + " ";
- }
- this->textBox2->Text = " ";
- string res2 = B.TSet_to_String();
- string* sos2 = new string[res.length() / 2 + 2];
- int count2 = 0;
- string_split_smart(res2, " ", sos2, count2);
- for (int i = 0; i < count2 + 1; i++)
- {
- this->textBox2->Text += Convert::ToString(atoi(sos2[i].c_str())) + " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment