fork download
  1. #pragma once
  2. #include <stdio.h>
  3. #include <conio.h>
  4. #include <sstream>
  5. #include <iostream>
  6. #include <thread>
  7. #include <mutex>
  8. #include <string>
  9. #include <cstdlib>
  10. #include <ctime>
  11. #include <fstream>
  12. using namespace std;
  13.  
  14. int k;
  15. int *arra;
  16.  
  17. namespace Project1 {
  18.  
  19. using namespace System;
  20. using namespace System::ComponentModel;
  21. using namespace System::Collections;
  22. using namespace System::Windows::Forms;
  23. using namespace System::Data;
  24. using namespace System::Drawing;
  25.  
  26. /// <summary>
  27. /// Сводка для MyForm
  28. /// </summary>
  29. public ref class MyForm : public System::Windows::Forms::Form
  30. {
  31. public:
  32. MyForm(void)
  33. {
  34. InitializeComponent();
  35. //
  36. //TODO: добавьте код конструктора
  37. //
  38. }
  39.  
  40. protected:
  41. /// <summary>
  42. /// Освободить все используемые ресурсы.
  43. /// </summary>
  44. ~MyForm()
  45. {
  46. if (components)
  47. {
  48. delete components;
  49. }
  50. }
  51.  
  52. protected:
  53. private: System::Windows::Forms::Button^ button1;
  54. private: System::Windows::Forms::TextBox^ textBox1;
  55.  
  56. private: System::Windows::Forms::Label^ label1;
  57. private: System::Windows::Forms::Button^ button2;
  58. private: System::ComponentModel::BackgroundWorker^ backgroundWorker1;
  59. private: System::Windows::Forms::Timer^ timer1;
  60. private: System::Windows::Forms::ProgressBar^ progressBar1;
  61. private: System::Windows::Forms::TextBox^ textBox2;
  62. private: System::ComponentModel::IContainer^ components;
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. protected:
  71.  
  72. private:
  73. /// <summary>
  74. /// Обязательная переменная конструктора.
  75. /// </summary>
  76.  
  77.  
  78. #pragma region Windows Form Designer generated code
  79. /// <summary>
  80. /// Требуемый метод для поддержки конструктора — не изменяйте
  81. /// содержимое этого метода с помощью редактора кода.
  82. /// </summary>
  83. void InitializeComponent(void)
  84. {
  85. this->components = (gcnew System::ComponentModel::Container());
  86. this->button1 = (gcnew System::Windows::Forms::Button());
  87. this->textBox1 = (gcnew System::Windows::Forms::TextBox());
  88. this->label1 = (gcnew System::Windows::Forms::Label());
  89. this->button2 = (gcnew System::Windows::Forms::Button());
  90. this->backgroundWorker1 = (gcnew System::ComponentModel::BackgroundWorker());
  91. this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
  92. this->progressBar1 = (gcnew System::Windows::Forms::ProgressBar());
  93. this->textBox2 = (gcnew System::Windows::Forms::TextBox());
  94. this->SuspendLayout();
  95. //
  96. // button1
  97. //
  98. this->button1->Location = System::Drawing::Point(26, 193);
  99. this->button1->Name = L"button1";
  100. this->button1->Size = System::Drawing::Size(75, 23);
  101. this->button1->TabIndex = 1;
  102. this->button1->Text = L"Генерация";
  103. this->button1->UseVisualStyleBackColor = true;
  104. this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click_1);
  105. //
  106. // textBox1
  107. //
  108. this->textBox1->Location = System::Drawing::Point(37, 49);
  109. this->textBox1->Multiline = true;
  110. this->textBox1->Name = L"textBox1";
  111. this->textBox1->Size = System::Drawing::Size(194, 99);
  112. this->textBox1->TabIndex = 2;
  113. this->textBox1->TextChanged += gcnew System::EventHandler(this, &MyForm::textBox1_TextChanged);
  114. //
  115. // label1
  116. //
  117. this->label1->AutoSize = true;
  118. this->label1->Location = System::Drawing::Point(23, 18);
  119. this->label1->Name = L"label1";
  120. this->label1->Size = System::Drawing::Size(82, 13);
  121. this->label1->TabIndex = 4;
  122. this->label1->Text = L"Розмір масиву";
  123. this->label1->Click += gcnew System::EventHandler(this, &MyForm::label1_Click);
  124. //
  125. // button2
  126. //
  127. this->button2->Location = System::Drawing::Point(197, 193);
  128. this->button2->Name = L"button2";
  129. this->button2->Size = System::Drawing::Size(75, 23);
  130. this->button2->TabIndex = 5;
  131. this->button2->Text = L"Сортировка";
  132. this->button2->UseVisualStyleBackColor = true;
  133. this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
  134. //
  135. // backgroundWorker1
  136. //
  137. this->backgroundWorker1->WorkerReportsProgress = true;
  138. this->backgroundWorker1->WorkerSupportsCancellation = true;
  139. this->backgroundWorker1->DoWork += gcnew System::ComponentModel::DoWorkEventHandler(this, &MyForm::backgroundWorker1_DoWork);
  140. //
  141. // timer1
  142. //
  143. this->timer1->Tick += gcnew System::EventHandler(this, &MyForm::timer1_Tick);
  144. //
  145. // progressBar1
  146. //
  147. this->progressBar1->Dock = System::Windows::Forms::DockStyle::Bottom;
  148. this->progressBar1->Location = System::Drawing::Point(0, 238);
  149. this->progressBar1->Name = L"progressBar1";
  150. this->progressBar1->Size = System::Drawing::Size(284, 23);
  151. this->progressBar1->Step = 1;
  152. this->progressBar1->TabIndex = 6;
  153. this->progressBar1->Click += gcnew System::EventHandler(this, &MyForm::progressBar1_Click_1);
  154. //
  155. // textBox2
  156. //
  157. this->textBox2->Location = System::Drawing::Point(156, 155);
  158. this->textBox2->Name = L"textBox2";
  159. this->textBox2->Size = System::Drawing::Size(100, 20);
  160. this->textBox2->TabIndex = 7;
  161. this->textBox2->TextChanged += gcnew System::EventHandler(this, &MyForm::textBox2_TextChanged);
  162. //
  163. // MyForm
  164. //
  165. this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  166. this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  167. this->ClientSize = System::Drawing::Size(284, 261);
  168. this->Controls->Add(this->textBox2);
  169. this->Controls->Add(this->progressBar1);
  170. this->Controls->Add(this->button2);
  171. this->Controls->Add(this->label1);
  172. this->Controls->Add(this->textBox1);
  173. this->Controls->Add(this->button1);
  174. this->Name = L"MyForm";
  175. this->Text = L"MyForm";
  176. this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
  177. this->ResumeLayout(false);
  178. this->PerformLayout();
  179.  
  180. }
  181. #pragma endregion
  182. private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
  183. }
  184. private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e) {
  185. }
  186. private: System::Void panel1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {
  187. }
  188. private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) {
  189. k = System::Convert::ToInt64(textBox1->Text);
  190. arra = new int[k];
  191. int min = 10;
  192. srand(time(NULL));
  193. ofstream fout;
  194. fout.open("fix.txt");
  195. if (k > min) {
  196. for (int i = 0; i < k; i++) {
  197. arra[i] = rand() % k;
  198. }
  199. for (int i = 0; i < k; i++) {
  200. fout << arra[i] << "\n";
  201. }
  202.  
  203. }
  204.  
  205. backgroundWorker1->RunWorkerAsync();
  206. this->timer1->Start();
  207.  
  208. }
  209.  
  210.  
  211. private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) {
  212. }
  213. private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
  214.  
  215. }
  216.  
  217. private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
  218. }
  219. private: System::Void backgroundWorker1_DoWork(System::Object^ sender, System::ComponentModel::DoWorkEventArgs^ e) {
  220. int tmp = 0;
  221. ofstream fou;
  222. fou.open("fixs.txt");
  223. for (int i = 0; i < k - 1; ++i) {
  224. int min_ind = i;
  225. for (int j = i + 1; j < k; j++) {
  226. if (arra[j] < arra[min_ind]) {
  227. min_ind = j;
  228. }
  229. }
  230. if (i != min_ind) {
  231. tmp = arra[i];
  232. arra[i] = arra[min_ind];
  233. arra[min_ind] = tmp;
  234. }
  235. fou << arra[i] << "\n";
  236. }
  237. }
  238. private: System::Void backgroundWorker1_ProgressChanged(System::Object^ sender, System::ComponentModel::ProgressChangedEventArgs^ e) {
  239. progressBar1->Value += e->ProgressPercentage;
  240. }
  241. private: System::Void progressBar1_Click_1(System::Object^ sender, System::EventArgs^ e) {
  242. }
  243. private: System::Void backgroundWorker1_RunWorkerCompleted(System::Object^ sender, System::ComponentModel::RunWorkerCompletedEventArgs^ e) {
  244. MessageBox::Show("Успех");
  245. }
  246. private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e) {
  247. progressBar1->Increment(1);
  248. if (progressBar1->Value == 100) {
  249. }
  250. }
  251. private: System::Void textBox2_TextChanged(System::Object^ sender, System::EventArgs^ e) {
  252. }
  253. };
  254. }
  255.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty