Upload
hasad-beasley
View
32
Download
6
Embed Size (px)
DESCRIPTION
הרצאה 11 – חלק א. מבוא למדעי המחשב לתעשייה וניהול. Structure. Structure. נגדיר מבנה structure עבור חבר מועדון בעל הפרטים הבאים: שם טלפון גיל. Structure member Dim name As String Dim phone As String Dim age As Integer End Structure. דוגמא 9 – הגדרה ושימוש ב structure. - PowerPoint PPT Presentation
Citation preview
המחשב למדעי מבואוניהול לתעשייה
א – 11הרצאה חלק
Structure
Structure
מבנה בעל structureנגדיר מועדון חבר עבור: הבאים הפרטים
שםטלפוןגיל
Structure member Dim name As String Dim phone As String Dim age As IntegerEnd Structure
Module Module1
Structure Member
Dim name As String
Dim phone As String
Dim age As Integer
End Structure
Sub Main()
Dim x As Member
x.name = "Chen"
x.phone = "08-9123232"
x.age = 18
Console.WriteLine("{0}, {1}, {2}", x.name, x.phone, x.age)
End Sub
End Module
ב – 9דוגמא ושימוש structureהגדרה
Module Module1
Structure Member
Dim name As String
Dim phone As String
Dim age As Integer
End Structure
Sub Main()
Dim x As Member
x.name = Console.ReadLine()
x.phone = Console.ReadLine()
x.age = Console.ReadLine()
Console.WriteLine("{0}, {1}, {2}", x.name, x.phone, x.age)
End Sub
End Module
ב – 10דוגמא ושימוש (structureהגדרה קלט ) עם
Module Module1
Structure Member
Dim name As String
Dim phone As String
Dim age As Integer
End Structure
Sub Main()
Dim x(2) As Member
For i = 0 To x.Length - 1
x(i).name = Console.ReadLine()
x(i).phone = Console.ReadLine()
x(i).age = Console.ReadLine()
Next
For i = 0 To x.Length - 1
Console.WriteLine("{0},{1},{2}",x(i).name,x(i).phone,x(i).age)
Next
End Sub
End Module
במערך structure –11דוגמא
Structure Member
Dim name As String
Dim phone As String
Dim age As Integer
End Structure
Sub Main()
Dim x(4) As Member
For i = 0 To x.Length - 1
x(i).name = Console.ReadLine()
x(i).phone = Console.ReadLine()
x(i).age = Console.ReadLine()
Next
Dim min As Integer = 120
For i = 0 To x.Length - 1
If x(i).age < min Then
min = x(i).age
End If
Next
Console.WriteLine("youngest age is: " & min)
End Sub
, structure –12דוגמא והדפסתו מינימלי ערך מציאת במערך
Module Module1
Structure Member
Dim name As String
Dim phone As String
Dim age As Integer
End Structure
Sub Main()
Dim x(2) As Member
For i = 0 To x.Length - 1
x(i).name = Console.ReadLine()
x(i).phone = Console.ReadLine()
x(i).age = Console.ReadLine()
Next
הבא בשקף ...המשך
הערך – 13דוגמא בעל של אחר שדה והדפסת מינימלי ערך מציאת
Dim min As Integer = 120
Dim n As String = ""
For i = 0 To x.Length - 1
If x(i).age < min Then
min = x(i).age
n = x(i).name
End If
Next
Console.WriteLine("name of youngest is: " & n)
End Sub
End Module
המשך – 13דוגמא