1 / 8

שיעור חזרה (השלמה) נושאים בעקבות השאלות שלכן...

שיעור חזרה (השלמה) נושאים בעקבות השאלות שלכן. חישוב סכום המספרים וכן מציאת מקסימום במערך. Sub Main() Dim x(9) As Integer Dim i As Integer For i = 0 To 9 x( i ) = Console .ReadLine () Next Dim sum As Integer = 0 Dim max = x(0) For i = 0 To 9

joshwa
Download Presentation

שיעור חזרה (השלמה) נושאים בעקבות השאלות שלכן...

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. שיעור חזרה (השלמה)נושאים בעקבות השאלות שלכן...

  2. חישוב סכום המספרים וכן מציאת מקסימום במערך Sub Main() Dim x(9) AsInteger DimiAsInteger Fori = 0 To 9 x(i) = Console.ReadLine() Next Dim sum AsInteger = 0 Dim max = x(0) Fori = 0 To 9 sum += x(i) If (x(i) > max) Then max = x(i) EndIf Next Console.WriteLine(“Sum is {0} and Max is {1} ", sum, max) EndSub

  3. מבנה (structure ) ומערך, מציאת ערך מינימלי והדפסתו StructureMember Dim name AsString Dim phone AsString Dim age AsInteger EndStructure Sub Main() Dimx(4) AsMember Fori = 0 Tox.Length - 1 x(i).name = Console.ReadLine() x(i).phone = Console.ReadLine() x(i).age = Console.ReadLine() Next Dim min AsInteger = 120, Dimn AsString = "" Fori = 0 Tox.Length - 1 If x(i).age < min Then min = x(i).age n = x(i).name EndIf Next Console.WriteLine("youngest age is: " & min& " youngest name is: " & n) EndSub

  4. מילוי מערך דו ממדי במספרים אקראיים והדפסתם SubgenRand(ByRef x, ByVal low, ByVal high) Dimi, j AsInteger Fori = 0 To 9 For j = 0 To 9 x(i, j) = Int((high - low + 1) * Rnd() + low) Next Next EndSub SubPrintArr(ByVal x) Dimi, j AsInteger Fori = 0 To 9 Console.Write("Row " & i & ":") For j = 0 To 9 Console.Write(" " & x(i, j) & " ") Next Console.WriteLine() Next EndSub

  5. המשך... SubMain() Dim a(9, 9) AsInteger Randomize() genRand(a, 1, 10) Console.WriteLine("1 to 10") PrintArr(a) genRand(a, 5, 10) Console.WriteLine("5 to 10") PrintArr(a) genRand(a, 3, 8) Console.WriteLine("3 to 8") PrintArr(a) EndSub

  6. משתנה בוליאני שמקבל מספרfalse =0, true <> 0 Dim b AsBoolean b = False Console.WriteLine("False b is: " & b) b = True Console.WriteLine("True b is: " & b) b = 0 Console.WriteLine("0 b is: " & b) b = 1 Console.WriteLine("1 b is: " & b) b = 2 Console.WriteLine("2 b is: " & b) b = -1 Console.WriteLine("-1 b is: " & b)

  7. קבצים Imports System.IO ModuleModule1 Sub Main() Dim Input AsInteger = 0, sum AsInteger = 0 Dim o AsStreamReader Dim c AsStreamWriter o = File.OpenText("C:\myfile.txt") While Input <> -1 Input = o.ReadLine() sum += Input EndWhile Console.WriteLine(sum) c = My.Computer.FileSystem.OpenTextFileWriter("C:\myOutfile.txt", True) c.WriteLine("the sum is: " & sum) c.Close() ' without close, doesnt write. Console.ReadKey() EndSub EndModule

  8. בהצלחה!

More Related