私はソート方法とランダムで作業しています。 Button1
作業する数、サイズ、および最大数の制限をランダム化するパラメーターを作成します。次に、選択した線形方法に従って、Button2
それらの数値を並べ替えてから、ストップウォッチを使用して所要時間を計測します。私は現在、:、、をテキストファイルで表示するために実装してsort method
います 。これで最初の部分が完了しました。プログラムがロードされたときに、結果を保存するファイルを作成するようにユーザーに促しました。 size
time_tosort
number of operations
結果をtextFileに追加し、結果を平均化するにはどうすればよいですか?また、ユーザーが並べ替えを終了した後、書き込み機能を閉じるためのボタンを追加する必要がありますか?
目的の形式の例 :sort method
、、、およびsize
time_tosort
number of operations
Linear 10000 .9 100,000,000
Linear 10000 .8 110,000,000
Linear 10000 .75 150,000,000
Linear 10000 .50 70,000,000
Linear 10000 .7375 107,500,000 ---- AVG
コード
namespace sortMachine
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Save()
{
var saveReport = new SaveFileDialog();
saveReport.Filter = "Text Files | *.txt";
var result = saveReport.ShowDialog();
if (result == DialogResult.Cancel || string.IsNullOrWhiteSpace(saveReport.FileName))
return;
using (var writer = new StreamWriter(saveReport.FileName))
{
writer.Write(textBox1.Text);
writer.Close();
}
}
private List<string> messages = new List<string>() { "Linear", "Bubble", "Index", "Other" };
private int clickCount = 0;
Stopwatch sw = new Stopwatch();
private void button1_Click(object sender, EventArgs e)
{
try
{
}
else if (textBox7.Text == "Bubble")
{
}
else if (textBox7.Text == "Index")
{
}
else if (textBox7.Text == "Other")
{
}
else if (textBox7.Text == "")
{
MessageBox.Show("Please input a sorting method");
}
}
private void Form1_Load(object sender, EventArgs e)
{
Save();
}
private void button3_Click(object sender, EventArgs e)
{
textBox7.Text = messages[clickCount];
clickCount++;
if (clickCount == messages.Count)
clickCount = 0;
}
}
}