PDA

View Full Version : سوال: مشکل در پیاده سازی الگوریتم صف



navidwhacker
چهارشنبه 04 خرداد 1390, 13:21 عصر
سلام یه برنامه صف نوشتم باسه دانشگاه ولی هر کاری میکنم خوب کار نمیکنه
مشکلش اینه که1.وقتی شماره باجه ها به 10 میرسه همه باجه ها شماره 10 رو صدا میکنن و نفر بعدی رو (11) صدا نمیزنن.
2.تابلویی که بالای صفحه گذاشتم رندم کار میکنه درصورتی که باید مرتب کار کنه.
لطفا کمک کنید واقعا خسته شدم.

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub
Public Class Form1

Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
T4.Text = T4.Text + 1
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If T4.Text > 0 And IsNumeric(T1.Text) = True And IsNumeric(T2.Text) = True And IsNumeric(T3.Text) = True Then
ListBox3.Items.Add(T3.Text)
If T1.Text > T2.Text Then
If T1.Text > T3.Text Then
If T1.Text + 1 <= T4.Text Then
T3.Text = T1.Text + 1

Else
MsgBox("!کسی در صف نمی باشد")


End If
Else
If T3.Text + 1 <= T4.Text Then
T3.Text = T3.Text + 1

Else
MsgBox("!کسی در صف نمی باشد")


End If


End If
Else
If T2.Text > T3.Text Then
If T2.Text + 1 <= T4.Text Then
T3.Text = T2.Text + 1

Else
MsgBox("!کسی در صف نمی باشد")


End If

Else
If T3.Text + 1 <= T4.Text Then
T3.Text = T3.Text + 1

Else
MsgBox("!کسی در صف نمی باشد")


End If


End If
L16.Text = "یک"
L12.Text = L11.Text
L18.Text = L17.Text
L11.Text = L10.Text
L17.Text = L16.Text
L10.Text = T3.Text
L16.Text = "سه"
End If
ElseIf T4.Text = 0 Then
MsgBox("!کسی در صف نمی باشد")
ElseIf IsNumeric(T1.Text) = False Or IsNumeric(T2.Text) = False Or IsNumeric(T3.Text) = False Then
T1.Text = "0"
T2.Text = "0"
T3.Text = "0"


End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If T4.Text > 0 And IsNumeric(T1.Text) = True And IsNumeric(T2.Text) = True And IsNumeric(T3.Text) = True Then

ListBox1.Items.Add(T1.Text)
If T1.Text > T2.Text Then
If T1.Text > T3.Text Then
If T1.Text + 1 <= T4.Text Then
T1.Text = T1.Text + 1

Else
MsgBox("!کسی در صف نمی باشد")


End If

Else
If T3.Text + 1 <= T4.Text Then
T1.Text = T3.Text + 1

Else
MsgBox("!کسی در صف نمی باشد")


End If


End If
Else
If T2.Text > T3.Text Then
If T2.Text + 1 <= T4.Text Then
T1.Text = T2.Text + 1

Else
MsgBox("!کسی در صف نمی باشد")


End If

Else
If T3.Text + 1 <= T4.Text Then
T1.Text = T3.Text + 1

Else
MsgBox("!کسی در صف نمی باشد")


End If


End If
L16.Text = "یک"
L12.Text = L11.Text
L18.Text = L17.Text
L11.Text = L10.Text
L17.Text = L16.Text
L10.Text = T1.Text
L16.Text = "یک"

End If
ElseIf T4.Text = 0 Then
MsgBox("!کسی در صف نمی باشد")
ElseIf IsNumeric(T1.Text) = False Or IsNumeric(T2.Text) = False Or IsNumeric(T3.Text) = False Then
T1.Text = "0"
T2.Text = "0"
T3.Text = "0"
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If T4.Text > 0 And IsNumeric(T1.Text) = True And IsNumeric(T2.Text) = True And IsNumeric(T3.Text) = True Then
ListBox2.Items.Add(T2.Text)
If T1.Text > T2.Text Then
If T1.Text > T3.Text Then
If T1.Text + 1 <= T4.Text Then
T2.Text = T1.Text + 1

Else
MsgBox("!کسی در صف نمی باشد")


End If

Else
If T3.Text + 1 <= T4.Text Then
T2.Text = T3.Text + 1

Else
MsgBox("!کسی در صف نمی باشد")


End If


End If
Else
If T2.Text > T3.Text Then
If T2.Text + 1 <= T4.Text Then
T2.Text = T2.Text + 1

Else
MsgBox("!کسی در صف نمی باشد")


End If


Else
If T3.Text + 1 <= T4.Text Then
T2.Text = T3.Text + 1

Else
MsgBox("!کسی در صف نمی باشد")


End If


End If
L16.Text = "یک"
L12.Text = L11.Text
L18.Text = L17.Text
L11.Text = L10.Text
L17.Text = L16.Text
L10.Text = T2.Text
L16.Text = "دو"
End If
ElseIf T4.Text = 0 Then
MsgBox("!کسی در صف نمی باشد")
ElseIf IsNumeric(T1.Text) = False Or IsNumeric(T2.Text) = False Or IsNumeric(T3.Text) = False Then
T1.Text = "0"
T2.Text = "0"
T3.Text = "0"


End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

7033070330

navidwhacker
چهارشنبه 04 خرداد 1390, 13:23 عصر
http://barnamenevis.org/attachment.php?attachmentid=70330&d=1306315246