Fix: правки в коде
This commit is contained in:
parent
bcd334d031
commit
c2f20659f9
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -127,7 +127,7 @@
|
||||
3. Сравниваем срединный элемент с заданным искомым элементом.
|
||||
4. Если искомое число больше среднего — продолжаем поиск в правой части массива (если он отсортирован по возрастанию): делим ее пополам, повторяя пункт 3. Если же заданное число меньше — алгоритм продолжит поиск в левой части массива, снова возвращаясь к пункту 3.
|
||||
|
||||
</value>
|
||||
Сложность: O(logN)</value>
|
||||
</data>
|
||||
<metadata name="fontDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
@ -136,7 +136,7 @@
|
||||
<data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAABF4AAASFCAYAAACWvRgTAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
|
||||
EQAACxEBf2RfkQAApzZJREFUeF7s/U+PHOeBLnoefYEW9QHaLa+PZVDb/gPIO0tqwPRKts6C9KIJqzeU
|
||||
DgAACw4BQL7hQQAApzZJREFUeF7s/U+PHOeBLnoefYEW9QHaLa+PZVDb/gPIO0tqwPRKts6C9KIJqzeU
|
||||
AWkk3DtzxZGOdHcWJVizG5OGvT2i0Z7VTNuEe+uG1V5d2AbEXlzg+khukqJsWrLUlZNPVr3Ft4JvZmVW
|
||||
5Z+IzN8PeEBWZmREZFZWVsRTb0T8lxEAAAAAq7CneAEAAABYDcULAAAAwIooXgAAAABWRPECAAAAsCKK
|
||||
FwAAAIAVUbwAAAAArIjiBQAAAGBFFC8AAAAAK6J4AQAAAFgRxQsAAADAiiheAAAAAFZE8QIAAACwIooX
|
||||
@ -855,7 +855,7 @@
|
||||
<data name="richTextBox2.Text" xml:space="preserve">
|
||||
<value>Данная программа позволяет вам посмотреть на графическую демонастрацию работы алгоритма "Бинарный поиск".
|
||||
|
||||
Для этого вам потребуется создать базовый целочисленный массив и указать какой элемент вы хотите найти. Так же если у вас есть сохраненный .bin файл с сохраненным состоянием там, то можете выгрузить его (CTRL+L).
|
||||
Для этого вам потребуется создать базовый целочисленный массив и указать какой элемент вы хотите найти. Так же если у вас есть сохраненный .bin или .json файл с состоянием, то можете загрузить его (CTRL+L).
|
||||
После того как у вас появится в главной форме массив нажмите на кнопку запуска алгоритма. Теперь вы можете пройтись вперед и просмотреть шаги выполнения алгоритма. Так же можно сохранить данный массив (CTRL+S).
|
||||
|
||||
Желаю вам успехов в изучении алгоритмов!</value>
|
||||
|
177
BinarySearch/BinarySearch/Forms/MainForm.Designer.cs
generated
177
BinarySearch/BinarySearch/Forms/MainForm.Designer.cs
generated
@ -45,15 +45,26 @@
|
||||
saveFileDialog = new SaveFileDialog();
|
||||
openFileDialog = new OpenFileDialog();
|
||||
labelMid = new Label();
|
||||
progressBarSteps = new ProgressBar();
|
||||
groupBox1 = new GroupBox();
|
||||
groupBox2 = new GroupBox();
|
||||
textBoxSteps = new TextBox();
|
||||
groupBox2 = new GroupBox();
|
||||
textBoxStep = new TextBox();
|
||||
groupBox3 = new GroupBox();
|
||||
labelResult = new Label();
|
||||
labelConditional = new Label();
|
||||
textBoxTarget = new TextBox();
|
||||
textBoxCurrent = new TextBox();
|
||||
statusStrip1 = new StatusStrip();
|
||||
toolStripStatusLabel1 = new ToolStripStatusLabel();
|
||||
toolStripStatusLabelElems = new ToolStripStatusLabel();
|
||||
toolStripStatusLabel2 = new ToolStripStatusLabel();
|
||||
toolStripProgressBarSteps = new ToolStripProgressBar();
|
||||
groupBoxTools.SuspendLayout();
|
||||
menuStrip1.SuspendLayout();
|
||||
groupBox1.SuspendLayout();
|
||||
groupBox2.SuspendLayout();
|
||||
groupBox3.SuspendLayout();
|
||||
statusStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxTools
|
||||
@ -65,9 +76,9 @@
|
||||
groupBoxTools.Controls.Add(buttonStepForward);
|
||||
groupBoxTools.Controls.Add(buttonInfo);
|
||||
groupBoxTools.Controls.Add(buttonAddData);
|
||||
groupBoxTools.Location = new Point(788, 27);
|
||||
groupBoxTools.Location = new Point(797, 27);
|
||||
groupBoxTools.Name = "groupBoxTools";
|
||||
groupBoxTools.Size = new Size(200, 384);
|
||||
groupBoxTools.Size = new Size(200, 255);
|
||||
groupBoxTools.TabIndex = 0;
|
||||
groupBoxTools.TabStop = false;
|
||||
groupBoxTools.Text = "Инструменты";
|
||||
@ -124,9 +135,10 @@
|
||||
//
|
||||
// flowLayoutPanelArray
|
||||
//
|
||||
flowLayoutPanelArray.Location = new Point(12, 96);
|
||||
flowLayoutPanelArray.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
flowLayoutPanelArray.Location = new Point(12, 101);
|
||||
flowLayoutPanelArray.Name = "flowLayoutPanelArray";
|
||||
flowLayoutPanelArray.Size = new Size(757, 36);
|
||||
flowLayoutPanelArray.Size = new Size(779, 36);
|
||||
flowLayoutPanelArray.TabIndex = 3;
|
||||
//
|
||||
// labelIsTarget
|
||||
@ -149,9 +161,10 @@
|
||||
//
|
||||
// flowLayoutPanelIndex
|
||||
//
|
||||
flowLayoutPanelIndex.Location = new Point(12, 56);
|
||||
flowLayoutPanelIndex.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
flowLayoutPanelIndex.Location = new Point(12, 61);
|
||||
flowLayoutPanelIndex.Name = "flowLayoutPanelIndex";
|
||||
flowLayoutPanelIndex.Size = new Size(757, 36);
|
||||
flowLayoutPanelIndex.Size = new Size(779, 36);
|
||||
flowLayoutPanelIndex.TabIndex = 4;
|
||||
//
|
||||
// menuStrip1
|
||||
@ -159,7 +172,7 @@
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(988, 24);
|
||||
menuStrip1.Size = new Size(997, 24);
|
||||
menuStrip1.TabIndex = 6;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
@ -189,12 +202,12 @@
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
saveFileDialog.Filter = "bin file | *.bin";
|
||||
saveFileDialog.Filter = "bin file (*.bin)|*.bin|json file (*.json)|*.json";
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
openFileDialog.FileName = "openFileDialog1";
|
||||
openFileDialog.Filter = "bin file | *.bin";
|
||||
openFileDialog.Filter = "All files (*.bin, *.json)|*.bin;*.json|Binary files (*.bin)|*.bin|JSON files (*.json)|*.json";
|
||||
//
|
||||
// labelMid
|
||||
//
|
||||
@ -204,59 +217,143 @@
|
||||
labelMid.Size = new Size(0, 15);
|
||||
labelMid.TabIndex = 7;
|
||||
//
|
||||
// progressBarSteps
|
||||
//
|
||||
progressBarSteps.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
progressBarSteps.Location = new Point(12, 377);
|
||||
progressBarSteps.Name = "progressBarSteps";
|
||||
progressBarSteps.Size = new Size(770, 23);
|
||||
progressBarSteps.TabIndex = 8;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
groupBox1.Controls.Add(textBoxSteps);
|
||||
groupBox1.Location = new Point(12, 310);
|
||||
groupBox1.Location = new Point(11, 182);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(133, 61);
|
||||
groupBox1.TabIndex = 9;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Количество шагов";
|
||||
//
|
||||
// textBoxSteps
|
||||
//
|
||||
textBoxSteps.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
textBoxSteps.Enabled = false;
|
||||
textBoxSteps.Location = new Point(6, 25);
|
||||
textBoxSteps.Name = "textBoxSteps";
|
||||
textBoxSteps.Size = new Size(110, 23);
|
||||
textBoxSteps.TabIndex = 0;
|
||||
textBoxSteps.Text = "0";
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
groupBox2.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
groupBox2.Controls.Add(textBoxStep);
|
||||
groupBox2.Location = new Point(151, 310);
|
||||
groupBox2.Location = new Point(150, 182);
|
||||
groupBox2.Name = "groupBox2";
|
||||
groupBox2.Size = new Size(131, 61);
|
||||
groupBox2.TabIndex = 10;
|
||||
groupBox2.TabStop = false;
|
||||
groupBox2.Text = "Актуальный шаг";
|
||||
//
|
||||
// textBoxSteps
|
||||
//
|
||||
textBoxSteps.Enabled = false;
|
||||
textBoxSteps.Location = new Point(6, 22);
|
||||
textBoxSteps.Name = "textBoxSteps";
|
||||
textBoxSteps.Size = new Size(121, 23);
|
||||
textBoxSteps.TabIndex = 0;
|
||||
//
|
||||
// textBoxStep
|
||||
//
|
||||
textBoxStep.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
textBoxStep.Enabled = false;
|
||||
textBoxStep.Location = new Point(4, 22);
|
||||
textBoxStep.Location = new Point(6, 25);
|
||||
textBoxStep.Name = "textBoxStep";
|
||||
textBoxStep.Size = new Size(121, 23);
|
||||
textBoxStep.Size = new Size(110, 23);
|
||||
textBoxStep.TabIndex = 1;
|
||||
textBoxStep.Text = "0";
|
||||
//
|
||||
// groupBox3
|
||||
//
|
||||
groupBox3.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
groupBox3.Controls.Add(labelResult);
|
||||
groupBox3.Controls.Add(labelConditional);
|
||||
groupBox3.Controls.Add(textBoxTarget);
|
||||
groupBox3.Controls.Add(textBoxCurrent);
|
||||
groupBox3.Location = new Point(287, 182);
|
||||
groupBox3.Name = "groupBox3";
|
||||
groupBox3.Size = new Size(313, 61);
|
||||
groupBox3.TabIndex = 11;
|
||||
groupBox3.TabStop = false;
|
||||
groupBox3.Text = "Рассчеты";
|
||||
//
|
||||
// labelResult
|
||||
//
|
||||
labelResult.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
labelResult.AutoSize = true;
|
||||
labelResult.Location = new Point(152, 32);
|
||||
labelResult.Name = "labelResult";
|
||||
labelResult.Size = new Size(0, 15);
|
||||
labelResult.TabIndex = 3;
|
||||
//
|
||||
// labelConditional
|
||||
//
|
||||
labelConditional.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
labelConditional.AutoSize = true;
|
||||
labelConditional.Location = new Point(52, 32);
|
||||
labelConditional.Name = "labelConditional";
|
||||
labelConditional.Size = new Size(0, 15);
|
||||
labelConditional.TabIndex = 2;
|
||||
//
|
||||
// textBoxTarget
|
||||
//
|
||||
textBoxTarget.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
textBoxTarget.Enabled = false;
|
||||
textBoxTarget.Location = new Point(105, 25);
|
||||
textBoxTarget.Name = "textBoxTarget";
|
||||
textBoxTarget.Size = new Size(40, 23);
|
||||
textBoxTarget.TabIndex = 1;
|
||||
//
|
||||
// textBoxCurrent
|
||||
//
|
||||
textBoxCurrent.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
textBoxCurrent.Enabled = false;
|
||||
textBoxCurrent.Location = new Point(6, 25);
|
||||
textBoxCurrent.Name = "textBoxCurrent";
|
||||
textBoxCurrent.Size = new Size(40, 23);
|
||||
textBoxCurrent.TabIndex = 0;
|
||||
//
|
||||
// statusStrip1
|
||||
//
|
||||
statusStrip1.Items.AddRange(new ToolStripItem[] { toolStripStatusLabel1, toolStripStatusLabelElems, toolStripStatusLabel2, toolStripProgressBarSteps });
|
||||
statusStrip1.Location = new Point(0, 261);
|
||||
statusStrip1.Name = "statusStrip1";
|
||||
statusStrip1.Size = new Size(997, 22);
|
||||
statusStrip1.TabIndex = 12;
|
||||
statusStrip1.Text = "statusStrip1";
|
||||
//
|
||||
// toolStripStatusLabel1
|
||||
//
|
||||
toolStripStatusLabel1.BackColor = SystemColors.Control;
|
||||
toolStripStatusLabel1.Name = "toolStripStatusLabel1";
|
||||
toolStripStatusLabel1.Size = new Size(137, 17);
|
||||
toolStripStatusLabel1.Text = "Количество элементов:";
|
||||
//
|
||||
// toolStripStatusLabelElems
|
||||
//
|
||||
toolStripStatusLabelElems.BackColor = SystemColors.Control;
|
||||
toolStripStatusLabelElems.Name = "toolStripStatusLabelElems";
|
||||
toolStripStatusLabelElems.Size = new Size(13, 17);
|
||||
toolStripStatusLabelElems.Text = "0";
|
||||
//
|
||||
// toolStripStatusLabel2
|
||||
//
|
||||
toolStripStatusLabel2.BackColor = SystemColors.Control;
|
||||
toolStripStatusLabel2.Name = "toolStripStatusLabel2";
|
||||
toolStripStatusLabel2.Size = new Size(197, 17);
|
||||
toolStripStatusLabel2.Text = "Прогресс выполнения алгоритма:";
|
||||
//
|
||||
// toolStripProgressBarSteps
|
||||
//
|
||||
toolStripProgressBarSteps.Name = "toolStripProgressBarSteps";
|
||||
toolStripProgressBarSteps.Size = new Size(100, 16);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
BackColor = Color.Moccasin;
|
||||
ClientSize = new Size(988, 412);
|
||||
ClientSize = new Size(997, 283);
|
||||
Controls.Add(statusStrip1);
|
||||
Controls.Add(groupBox3);
|
||||
Controls.Add(groupBox2);
|
||||
Controls.Add(groupBox1);
|
||||
Controls.Add(progressBarSteps);
|
||||
Controls.Add(labelMid);
|
||||
Controls.Add(flowLayoutPanelIndex);
|
||||
Controls.Add(labelTarget);
|
||||
@ -274,6 +371,10 @@
|
||||
groupBox1.PerformLayout();
|
||||
groupBox2.ResumeLayout(false);
|
||||
groupBox2.PerformLayout();
|
||||
groupBox3.ResumeLayout(false);
|
||||
groupBox3.PerformLayout();
|
||||
statusStrip1.ResumeLayout(false);
|
||||
statusStrip1.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@ -302,5 +403,15 @@
|
||||
private GroupBox groupBox2;
|
||||
private TextBox textBoxSteps;
|
||||
private TextBox textBoxStep;
|
||||
private GroupBox groupBox3;
|
||||
private Label labelResult;
|
||||
private Label labelConditional;
|
||||
private TextBox textBoxTarget;
|
||||
private TextBox textBoxCurrent;
|
||||
private StatusStrip statusStrip1;
|
||||
private ToolStripProgressBar toolStripProgressBarSteps;
|
||||
private ToolStripStatusLabel toolStripStatusLabel1;
|
||||
private ToolStripStatusLabel toolStripStatusLabelElems;
|
||||
private ToolStripStatusLabel toolStripStatusLabel2;
|
||||
}
|
||||
}
|
@ -63,9 +63,10 @@ public partial class MainForm : Form
|
||||
_stateStorage.Reset();
|
||||
_visualizer.UpdateFlowLayoutPanel();
|
||||
_manager.ExecuteBinarySearch(_parameters);
|
||||
progressBarSteps.Maximum = _stateStorage.GetStatesCount();
|
||||
toolStripStatusLabelElems.Text = _parameters?.Array?.Count.ToString();
|
||||
toolStripProgressBarSteps.Maximum = _stateStorage.GetStatesCount();
|
||||
textBoxSteps.Text = _stateStorage.GetStatesCount().ToString();
|
||||
progressBarSteps.Value = 0;
|
||||
toolStripProgressBarSteps.Value = 0;
|
||||
textBoxStep.Text = 0.ToString();
|
||||
toolStripMenuItemSave.Enabled = true;
|
||||
buttonStepForward.Enabled = true;
|
||||
@ -80,7 +81,7 @@ public partial class MainForm : Form
|
||||
private void buttonStepForward_Click(object sender, EventArgs e)
|
||||
{
|
||||
SearchState? searchState = _stateStorage.GetNextState();
|
||||
progressBarSteps.Value = _stateStorage.GetCurrentIndex()+1;
|
||||
toolStripProgressBarSteps.Value = _stateStorage.GetCurrentIndex()+1;
|
||||
textBoxStep.Text = (_stateStorage.GetCurrentIndex() + 1).ToString();
|
||||
SearchState? searchStateCheck = _stateStorage.GetNextState();
|
||||
if (searchStateCheck == null && searchState != null)
|
||||
@ -101,6 +102,7 @@ public partial class MainForm : Form
|
||||
{
|
||||
return;
|
||||
}
|
||||
calculateInfo(searchState);
|
||||
_visualizer.Visualize(searchState);
|
||||
buttonStepForward.Enabled = true;
|
||||
buttonStepBack.Enabled = true;
|
||||
@ -118,13 +120,35 @@ public partial class MainForm : Form
|
||||
{
|
||||
return;
|
||||
}
|
||||
progressBarSteps.Value = _stateStorage.GetCurrentIndex()+1;
|
||||
toolStripProgressBarSteps.Value = _stateStorage.GetCurrentIndex()+1;
|
||||
textBoxStep.Text = (_stateStorage.GetCurrentIndex() + 1).ToString();
|
||||
calculateInfo(searchState);
|
||||
_visualizer.Visualize(searchState);
|
||||
buttonStepForward.Enabled = true;
|
||||
buttonStepBack.Enabled = true;
|
||||
}
|
||||
|
||||
private void calculateInfo(SearchState state)
|
||||
{
|
||||
int currentNumber = state.Array[state.Mid];
|
||||
int target = state.Target;
|
||||
textBoxCurrent.Text = currentNumber.ToString();
|
||||
textBoxTarget.Text = target.ToString();
|
||||
if (target < currentNumber)
|
||||
{
|
||||
labelConditional.Text = "больше";
|
||||
labelResult.Text = "берём левый подмассив";
|
||||
} else if (target > currentNumber)
|
||||
{
|
||||
labelConditional.Text = "меньше";
|
||||
labelResult.Text = "берём правый подмассив";
|
||||
} else
|
||||
{
|
||||
labelConditional.Text = "равно";
|
||||
labelResult.Text = "берём это значение";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обработчик события открытия формы информации
|
||||
/// </summary>
|
||||
|
@ -126,4 +126,7 @@
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>267, 17</value>
|
||||
</metadata>
|
||||
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>400, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -1,4 +1,5 @@
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace BinarySearch.State;
|
||||
|
||||
@ -101,7 +102,7 @@ public class StateStorage
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Сохранение хранилища в бинарный файл
|
||||
/// Сохранение хранилища в бинарный файл или JSON файл
|
||||
/// </summary>
|
||||
/// <param name="filename"></param>
|
||||
/// <returns></returns>
|
||||
@ -109,11 +110,30 @@ public class StateStorage
|
||||
{
|
||||
try
|
||||
{
|
||||
string extension = Path.GetExtension(filename).ToLower();
|
||||
|
||||
if (extension == ".bin")
|
||||
{
|
||||
// Сохранение в бинарный формат
|
||||
BinaryFormatter formatter = new BinaryFormatter();
|
||||
using FileStream fs = new FileStream(filename, FileMode.Create);
|
||||
#pragma warning disable SYSLIB0011
|
||||
formatter.Serialize(fs, states);
|
||||
#pragma warning restore SYSLIB0011
|
||||
}
|
||||
else if (extension == ".json")
|
||||
{
|
||||
// Сохранение в формат JSON
|
||||
string json = JsonSerializer.Serialize(states);
|
||||
File.WriteAllText(filename, json);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Неподдерживаемое расширение файла
|
||||
Console.WriteLine("Unsupported file extension");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -124,7 +144,7 @@ public class StateStorage
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Загрузка хранилища из бинарного файла
|
||||
/// Загрузка хранилища из бинарного файла или JSON файла
|
||||
/// </summary>
|
||||
/// <param name="filename"></param>
|
||||
/// <returns></returns>
|
||||
@ -132,11 +152,30 @@ public class StateStorage
|
||||
{
|
||||
try
|
||||
{
|
||||
string extension = Path.GetExtension(filename).ToLower();
|
||||
|
||||
if (extension == ".bin")
|
||||
{
|
||||
// Загрузка из бинарного файла
|
||||
BinaryFormatter formatter = new BinaryFormatter();
|
||||
using FileStream fs = new FileStream(filename, FileMode.Open);
|
||||
#pragma warning disable SYSLIB0011
|
||||
states = (List<SearchState>)formatter.Deserialize(fs);
|
||||
#pragma warning restore SYSLIB0011
|
||||
}
|
||||
else if (extension == ".json")
|
||||
{
|
||||
// Загрузка из файла в формате JSON
|
||||
string json = File.ReadAllText(filename);
|
||||
states = JsonSerializer.Deserialize<List<SearchState>>(json);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Неподдерживаемое расширение файла
|
||||
Console.WriteLine("Unsupported file extension");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -14,7 +14,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("BinarySearch")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+bcd334d0311ab8e6c59928bb18adb95b23630025")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("BinarySearch")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("BinarySearch")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
@ -1 +1 @@
|
||||
1d747fb8a31ff8aaece430d2476a61103b8e3209701086c3b8734998b4b745be
|
||||
695aa2c69608c0253b250b29a1ce56a3094f8fd99413ff79c586e97848417cf0
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user