این پروژه آپولویی بود که برای ترم چهار باید تحویل میدادیم، امیدوارم به دردتون بخوره البته اینم بگم که این مربوط به درس ساختمون داده میشه
در مورد انواع مرتب سازیها اومدیم الگوریتم مربوط به اونها رو نوشتیم که البته در این پروژه آقایون (صالحیان و حسنپور) خیلی نقش موثری در انجامش داشتن ، جا داره همین جا از این آقایون محترم تشکر دوباره داشته باشم
کلاس node
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ProjectNewDecipline1
{
class Node
{
public int data;
public Node Rlink;
public Node LLink;
public Node(int element)
{
data = element;
Rlink = null;
LLink = null;
}
}
}
کلاس List
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ProjectNewDecipline1
{
class CList
{
public Node first1 = null;
public Node first2 = null;
int counter = 0;
int counter1 = 0;
//======================================
bool IsEmpty1()
{
if (first1 == null)
return true;
return false;
}
//--------------------------------------------
bool IsEmpty2()
{
if (first2 == null)
return true;
return false;
}
int top = 0;
//===============================================
public int InsertData1(int item)
{
Node current = first1;
Node N = new Node(item);
if (IsEmpty1())
{
first1 = N;
counter++;
counter1++;
top++;
}
else
{
while (current.Rlink != null)
current = current.Rlink;
current.Rlink = N;
counter++;
counter1++;
top++;
}
return item;
}
//----------------------------------------
public void DeleteForInsertData1(Node pointer)
{
Node One = first1;
while (One != null)
{
One = One.Rlink;
first1 = null;
first1 = One;
}
first1 = null;
}
//-------------------------------------------
public int InsertData2(int item2)
{
Node current = first2;
Node N = new Node(item2);
if (IsEmpty2())
{
first2 = N;
}
else
{
while (current.Rlink != null)
current = current.Rlink;
current.Rlink = N;
}
return item2;
}
//==============================================
string CapacityEndHobabi;
public string Hobabi(Node Pointer)//:),True
{
Node Current = first1;
Node current1 = first1;
Node check = first1;
while (counter != 0)
{
counter1 = top;
Current = first1;
CapacityEndHobabi = "";
//while (counter1 != 0)
//{
while (Current.Rlink != null)
{
if (Current.data > Current.Rlink.data)
{
int temp;
temp = Current.data;
Current.data = Current.Rlink.data;
Current.Rlink.data = temp;
}
CapacityEndHobabi += " " + Current.data;
Current = Current.Rlink;
//}
//counter1--;
}
counter--;
}
return CapacityEndHobabi.ToString() + " " + Current.data;
}
//===================================================================
string CapacityEndFast;
int CapacitySmall;
int changeEnd;
Node curr1;
Node curr4; Node f1;
public string Fast(Node Pointer)
{
Node curr2 = first1;
Node curr3;
int CapacityBig;
int Change;
Node curNode = first1;
Node curMin= first1;
Node curMax = first1;
int min = curMin.data;
Node chekmin = first1;
while (curMin != null)
{
if (min > curMin.data)
{
min = curMin.data;
}
curMin = curMin.Rlink;
}
int max = curMax.data;
Node checkmax = first1;
while (curMax != null)
{
if (max < curMax.data)
{
max = curMax.data;
checkmax = curMax;
}
curMax = curMax.Rlink;
}
////-----------------------------
//Node f1 = first1;
//while (f1.Rlink != null)
//{
// f1 = f1.Rlink;
//}
//if (f1.data == max)
// return "false";
////-------------------------------
while (true)
{
curr1 = first1;
if (max == first1.data)
{
CapacityBig = first1.data;
}
else
{
while (first1.data > curr1.Rlink.data)
{
curr1 = curr1.Rlink;
}
curr1 = curr1.Rlink;//////زمانی که گره محور بزرگترین مقدار قرار میگیرد دچار خطا میشود
CapacityBig = curr1.data;
}
while (curr2.Rlink != null)
{
curr2.Rlink.LLink = curr2;
curr2 = curr2.Rlink;
}
curr4 = curr2;
curr2 = first1;
while (curr1 != null)
{
CheckNode = curr1;
checkMin = CheckNode;
int min = curr2.data;
for (int i = 0; i < counter; i++)
{
if (min > CheckNode.data)
{
min = CheckNode.data;
checkMin = CheckNode;
}
if (CheckNode.Rlink != null)
{
CheckNode = CheckNode.Rlink;
}
Node SeleNode = first1;
while (SeleNode.Rlink != null)
{
CE11 += " " + SeleNode.data;
SeleNode = SeleNode.Rlink;
}
return CE11 + " " + SeleNode.data;
}
//-----------------------------------------------
public int BinarySearch(int item, Node Pointer)
{
Node midnode, max = first1;
int low, mid, high;
low = 0;
high = counter - 1;
while (low <= high)
{
midnode = first1;
mid = (low + high) / 2;
for (int j = 0; j < mid; j++)
{
midnode = midnode.Rlink;
}
if (midnode.data == item)
return mid;
else if (midnode.data < item)
low = mid + 1;
else
high = mid - 1;
}
return -1;
}
}
}
فرم باینری سرچ:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ProjectNewDecipline1
{
public partial class FormBinarySearch : Form
{
public FormBinarySearch()
{
InitializeComponent();
}
CList MyList = new CList();
private void txt_EnterData_KeyPress(object sender, KeyPressEventArgs e)
{
try
{
if (e.KeyChar=='\r')
{
lbl_ShowEnterData.Text += " " + MyList.InsertData1(Convert.ToInt32(txt_EnterData.Text));
txt_EnterData.Text = "";
}
}
catch (Exception ecp)
{
MessageBox.Show(ecp.Message);
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ProjectNewDecipline1
{
public partial class FormEdgham : Form
{
public FormEdgham()
{
InitializeComponent();
}
CList MyList = new CList();
private void txt_EnterDataOne_KeyPress(object sender, KeyPressEventArgs e)
{
try
{
if (e.KeyChar == '\r')
{
lbl_ShowEnterDataOne.Text += " " + MyList.InsertData1(Convert.ToInt32(txt_EnterDataOne.Text));
txt_EnterDataOne.Text = "";
}
}
catch (Exception ecp)
{
MessageBox.Show(ecp.Message);
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ProjectNewDecipline1
{
public partial class FormFast : Form
{
public FormFast()
{
InitializeComponent();
}
CList MyList = new CList();
//==================================================================
private void btn_ClickFast_Click(object sender, EventArgs e)
{
lbl_ShowChangeFast.Text = "";
try
{
lbl_ShowChangeFast.Text += " " + MyList.Fast(MyList.first1);
}
catch (Exception ecp)
{
MessageBox.Show(ecp.Message);
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ProjectNewDecipline1
{
public partial class FormHobabi : Form
{
public FormHobabi()
{
InitializeComponent();
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ProjectNewDecipline1
{
public partial class FormSelection : Form
{
public FormSelection()
{
InitializeComponent();
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ProjectNewDecipline1
{
public partial class FormShell : Form
{
public FormShell()
{
InitializeComponent();
}
CList MyList = new CList();
private void btn_ClickShowShell_Click(object sender, EventArgs e)
{
try
{
lbl_ShowEnterChangeData.Text +="ShowChangeData : "+ " " + MyList.Shell(MyList.first1);
}
catch (Exception ecp)
{
MessageBox.Show(ecp.Message);
}
}
علاقه مندی ها (Bookmarks)