HICONT

MyForm

Oct 13th, 2022 (edited)
1,455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.93 KB | None | 0 0
  1. //После namespace:
  2. void string_split_smart(string str, string razd, string*& result, int& new_count) {
  3.         for (int i = 0; i < str.length(); i++) {
  4.             int l = razd.find(str[i]);
  5.             if (l < 0 || l > razd.length()) {
  6.                 result[new_count] = result[new_count] + str[i];
  7.             }
  8.             else {
  9.                 if (str[i] == ' ') {
  10.                     if (result[new_count] != "") {
  11.                         result[++new_count] = "";
  12.                     }
  13.                 }
  14.                 else {
  15.                     if (result[new_count] != "") {
  16.                         new_count++;
  17.                     }
  18.                     result[new_count] = str[i];
  19.                     result[++new_count] = "";
  20.                 }
  21.             }
  22.         }
  23.     }
  24.  
  25. //После кода компилятора:
  26. private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e) {
  27.  
  28. }
  29. //Universe:
  30. private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
  31.     if (this->textBox1->Text != "")
  32.     {
  33.         u_size = Convert::ToInt64(this->textBox3->Text);
  34.     }
  35. }
  36.  
  37. //And
  38. private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
  39. {
  40.     this->textBox4->Text = " ";
  41.  
  42.     TSet A(u_size);
  43.     TSet B(u_size);
  44.     for (int i = 0; i < this->textBox1->Text->Split(' ')->Length; i++)
  45.     {
  46.         A.Add(Convert::ToInt32(this->textBox1->Text->Split(' ')[i]));
  47.     }
  48.     for (int i = 0; i < this->textBox2->Text->Split(' ')->Length; i++)
  49.     {
  50.         B.Add(Convert::ToInt32(this->textBox2->Text->Split(' ')[i]));
  51.     }
  52.     string res = (A & B).TSet_to_String();
  53.     string* sos = new string[res.length() / 2 + 2];
  54.     int count = 0;
  55.     string_split_smart(res, " ", sos, count);
  56.     for (int i = 0; i < count+1; i++)
  57.     {
  58.         this->textBox4->Text += Convert::ToString(atoi(sos[i].c_str())) + " ";
  59.     }
  60.     this->textBox2->Text = " ";
  61.     string res2 = B.TSet_to_String();
  62.     string* sos2 = new string[res.length() / 2 + 2];
  63.     int count2 = 0;
  64.     string_split_smart(res2, " ", sos2, count2);
  65.     for (int i = 0; i < count2 + 1; i++)
  66.     {
  67.         this->textBox2->Text += Convert::ToString(atoi(sos2[i].c_str())) + " ";
  68.     }
  69.     this->textBox1->Text = " ";
  70.     string res3 = A.TSet_to_String();
  71.     string* sos3 = new string[res.length() / 2 + 2];
  72.     int count3 = 0;
  73.     string_split_smart(res3, " ", sos3, count3);
  74.     for (int i = 0; i < count3 + 1; i++)
  75.     {
  76.         this->textBox1->Text += Convert::ToString(atoi(sos3[i].c_str())) + " ";
  77.     }
  78. }
  79. //Or
  80. private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)
  81. {
  82.     this->textBox4->Text = " ";
  83.  
  84.     TSet A(u_size);
  85.     TSet B(u_size);
  86.     for (int i = 0; i < this->textBox1->Text->Split(' ')->Length; i++)
  87.     {
  88.         A.Add(Convert::ToInt32(this->textBox1->Text->Split(' ')[i]));
  89.     }
  90.     for (int i = 0; i < this->textBox2->Text->Split(' ')->Length; i++)
  91.     {
  92.         B.Add(Convert::ToInt32(this->textBox2->Text->Split(' ')[i]));
  93.     }
  94.     string res = (A | B).TSet_to_String();
  95.     string* sos = new string[res.length() / 2 + 2];
  96.     int count = 0;
  97.     string_split_smart(res, " ", sos, count);
  98.     for (int i = 0; i < count + 1; i++)
  99.     {
  100.         this->textBox4->Text += Convert::ToString(atoi(sos[i].c_str())) + " ";
  101.     }
  102.     this->textBox2->Text = " ";
  103.     string res2 = B.TSet_to_String();
  104.     string* sos2 = new string[res.length() / 2 + 2];
  105.     int count2 = 0;
  106.     string_split_smart(res2, " ", sos2, count2);
  107.     for (int i = 0; i < count2 + 1; i++)
  108.     {
  109.         this->textBox2->Text += Convert::ToString(atoi(sos2[i].c_str())) + " ";
  110.     }
  111.     this->textBox1->Text = " ";
  112.     string res3 = A.TSet_to_String();
  113.     string* sos3 = new string[res.length() / 2 + 2];
  114.     int count3 = 0;
  115.     string_split_smart(res3, " ", sos3, count3);
  116.     for (int i = 0; i < count3 + 1; i++)
  117.     {
  118.         this->textBox1->Text += Convert::ToString(atoi(sos3[i].c_str())) + " ";
  119.     }
  120. }
  121. //Complement A
  122. private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e)
  123. {
  124.     this->textBox4->Text = " ";
  125.  
  126.     TSet A(u_size);
  127.    
  128.     for (int i = 0; i < this->textBox1->Text->Split(' ')->Length; i++)
  129.     {
  130.         A.Add(Convert::ToInt32(this->textBox1->Text->Split(' ')[i]));
  131.     }
  132.     string res = (~A).TSet_to_String();
  133.     string* sos = new string[res.length() / 2 + 2];
  134.     int count = 0;
  135.     string_split_smart(res, " ", sos, count);
  136.     for (int i = 0; i < count + 1; i++)
  137.     {
  138.         this->textBox4->Text += Convert::ToString(atoi(sos[i].c_str())) + " ";
  139.     }
  140.     this->textBox2->Text = " ";
  141.     string res2 = A.TSet_to_String();
  142.     string* sos2 = new string[res.length() / 2 + 2];
  143.     int count2 = 0;
  144.     string_split_smart(res2, " ", sos2, count2);
  145.     for (int i = 0; i < count2 + 1; i++)
  146.     {
  147.         this->textBox1->Text += Convert::ToString(atoi(sos2[i].c_str())) + " ";
  148.     }
  149. }
  150. //Complement B
  151. private: System::Void button8_Click(System::Object^ sender, System::EventArgs^ e)
  152. {
  153.     this->textBox4->Text = " ";
  154.  
  155.     TSet B(u_size);
  156.  
  157.     for (int i = 0; i < this->textBox2->Text->Split(' ')->Length; i++)
  158.     {
  159.         B.Add(Convert::ToInt32(this->textBox2->Text->Split(' ')[i]));
  160.     }
  161.     string res = (~B).TSet_to_String();
  162.     string* sos = new string[res.length() / 2 + 2];
  163.     int count = 0;
  164.     string_split_smart(res, " ", sos, count);
  165.     for (int i = 0; i < count + 1; i++)
  166.     {
  167.         this->textBox4->Text += Convert::ToString(atoi(sos[i].c_str())) + " ";
  168.     }
  169.     this->textBox2->Text = " ";
  170.     string res2 = B.TSet_to_String();
  171.     string* sos2 = new string[res.length() / 2 + 2];
  172.     int count2 = 0;
  173.     string_split_smart(res2, " ", sos2, count2);
  174.     for (int i = 0; i < count2 + 1; i++)
  175.     {
  176.         this->textBox2->Text += Convert::ToString(atoi(sos2[i].c_str())) + " ";
  177.     }
  178. }
  179.         B.Add(Convert::ToInt32(this->textBox2->Text->Split(' ')[i]));
  180.     }
  181.     string res = (A | B).TSet_to_String();
  182.     string* sos = new string[res.length() / 2 + 2];
  183.     int count = 0;
  184.     string_split_smart(res, " ", sos, count);
  185.     for (int i = 0; i < count + 1; i++)
  186.     {
  187.         this->textBox4->Text += Convert::ToString(atoi(sos[i].c_str())) + " ";
  188.     }
  189. }
  190. //Complement A
  191. private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e)
  192. {
  193.     this->textBox4->Text = " ";
  194.  
  195.     TSet A(u_size);
  196.    
  197.     for (int i = 0; i < this->textBox1->Text->Split(' ')->Length; i++)
  198.     {
  199.         A.Add(Convert::ToInt32(this->textBox1->Text->Split(' ')[i]));
  200.     }
  201.     string res = (~A).TSet_to_String();
  202.     string* sos = new string[res.length() / 2 + 2];
  203.     int count = 0;
  204.     string_split_smart(res, " ", sos, count);
  205.     for (int i = 0; i < count + 1; i++)
  206.     {
  207.         this->textBox4->Text += Convert::ToString(atoi(sos[i].c_str())) + " ";
  208.     }
  209. }
  210. //Complement B
  211. private: System::Void button8_Click(System::Object^ sender, System::EventArgs^ e)
  212. {
  213.     this->textBox4->Text = " ";
  214.  
  215.     TSet B(u_size);
  216.  
  217.     for (int i = 0; i < this->textBox2->Text->Split(' ')->Length; i++)
  218.     {
  219.         B.Add(Convert::ToInt32(this->textBox2->Text->Split(' ')[i]));
  220.     }
  221.     string res = (~B).TSet_to_String();
  222.     string* sos = new string[res.length() / 2 + 2];
  223.     int count = 0;
  224.     string_split_smart(res, " ", sos, count);
  225.     for (int i = 0; i < count + 1; i++)
  226.     {
  227.         this->textBox4->Text += Convert::ToString(atoi(sos[i].c_str())) + " ";
  228.     }
  229.     this->textBox2->Text = " ";
  230.     string res2 = B.TSet_to_String();
  231.     string* sos2 = new string[res.length() / 2 + 2];
  232.     int count2 = 0;
  233.     string_split_smart(res2, " ", sos2, count2);
  234.     for (int i = 0; i < count2 + 1; i++)
  235.     {
  236.         this->textBox2->Text += Convert::ToString(atoi(sos2[i].c_str())) + " ";
  237.     }
  238. }
Advertisement
Add Comment
Please, Sign In to add comment