לולאות- loops שני סוגי לולאות:

Download לולאות- Loops שני סוגי לולאות:

Post on 06-Jan-2018

221 views

Category:

Documents

4 download

Embed Size (px)

DESCRIPTION

לולאות- Loops 2. Do Loop While - תיכנס ללולאה בכל מקרה, ואז תבדוק אם התנאי מתקיים, ואם כן, תמשיך להיכנס ללולאה ווריאציה: Do Loop Until - תיכנס ללולאה בכל מקרה, ואז תבדוק אם התנאי לא מתקיים, ואם לא, תמשיך להיכנס ללולאה Do-Loop-While מתבצע לפחות פעם אחת ובודק. אם התנאי קיים ממשיך. Do-Loop-Until מתבצע לפחות פעם אחת ובודק. אם התנאי לא קיים ממשיך.

TRANSCRIPT

- Loops :
1. Do While Loop- , : Do Until Loop- , Do-While-Loop Do Until Loop - Loops 2. Do Loop While- , , , :Do Loop Until- , , , Do-Loop-While . . Do-Loop-Until . . Do-While-Loop - Do [{While |Until}] []
[Exit Do] Loop Do While , Do Until - , : Do -Loop . . Alternative Coding for Do-While-Loop
[] [Exit Do] Loop , : While [Exit While] End While Do-While
Count 1 Count x = 9 /= x /= means x = x / 3 => x = 3 &= y &= Johnmeans y = y & John, y = Hello John : A , 8 B , 57382
: True A -B, False Found True C=A B B\10 Found A, B
Found 10 : . : i e, -i -c e i, -e c e i : i , , e i ( ), i e c, chief not cheif, but receive not recieve y c c first e i second third i
First letter in sentence e Second letter in sentence Check for Spelling Mistake Text pos -1, num 0 pos = -1?
Check for Problem pos =-1 pos = 0 i
i pos pos =-1 pos = 0 i -num pos+1 e pos = 1 i" pos >= 2 = 2 And pos < mila.Length - 1 Then If mila.Chars(pos - 1) = "c" And mila.Chars(pos + 1) = "e" _ Or mila.Chars(pos - 2) "c" And mila.Chars(pos - 1) = "e" Then Console.WriteLine("taut bekom {0}", pos) End If Else If mila.Chars(pos - 2) "c" And mila.Chars(pos - 1) = "e" Then num += 1 Loop Until pos = -1 end sub "i" "i" . "i" indexof - "i" . 5 , . 1. pos = -1. ( ). 2. pos=0, "i" , "e" 3. pos=1, "i" , , "c" - "e" , 4. pos>=2, "i" , "c" - "e" , "xe" , "x" -"c", . 5. "i" , "xe" , "x" -"c", . 1.
2. ( ) . , 3. . For Next Loop General Format:
For counter [as datatype] = first to last [Step ] [] [Exit For] [] Next [counter] Ex2.9-BasicForLoop 1: Dim Count As Integer, Ans As String
2: For Count = 1 To 10 3: Console.WriteLine("Counting at {0}, Count) 4: Console.WriteLine("Another? Yes or No") 5: Ans = Console.ReadLine() 6: If Ans.ToUpper = "NO" Then Exit For 'Chance to leave early.1 line If 7:Next Count The word count is optional Ex2.9-BasicForLoop
2,3,8: Basic For Loop -1 10. , , . 2, ,STEP 2 1,3,5,7 -9 . 2. [as datatype] 2 : For Count as Integer = 1 To 10, Count ( AsInteger). 6: ExitFor . NatzeretN Natzeret