90 likes | 199 Views
הרצאה 11 – חלק א. מבוא למדעי המחשב לתעשייה וניהול. Structure. Structure. נגדיר מבנה structure עבור חבר מועדון בעל הפרטים הבאים: שם טלפון גיל. Structure member Dim name As String Dim phone As String Dim age As Integer End Structure. דוגמא 9 – הגדרה ושימוש ב structure.
E N D
הרצאה 11 – חלק א מבוא למדעי המחשב לתעשייה וניהול
Structure • נגדיר מבנה structure עבור חבר מועדון בעל הפרטים הבאים: • שם • טלפון • גיל • Structuremember • Dim name AsString • Dim phone AsString • Dim age AsInteger • EndStructure
דוגמא 9 – הגדרה ושימוש ב structure ModuleModule1 StructureMember Dim name AsString Dim phone AsString Dim age AsInteger EndStructure Sub Main() Dim x AsMember x.name = "Chen" x.phone = "08-9123232" x.age = 18 Console.WriteLine("{0}, {1}, {2}", x.name, x.phone, x.age) EndSub EndModule
דוגמא 10 – הגדרה ושימוש ב structure (עם קלט) ModuleModule1 StructureMember Dim name AsString Dim phone AsString Dim age AsInteger EndStructure Sub Main() Dim x AsMember x.name = Console.ReadLine() x.phone = Console.ReadLine() x.age = Console.ReadLine() Console.WriteLine("{0}, {1}, {2}", x.name, x.phone, x.age) EndSub EndModule
דוגמא 11 –structure במערך ModuleModule1 StructureMember Dim name AsString Dim phone AsString Dim age AsInteger EndStructure Sub Main() Dim x(2) AsMember Fori = 0 Tox.Length - 1 x(i).name = Console.ReadLine() x(i).phone = Console.ReadLine() x(i).age = Console.ReadLine() Next Fori = 0 Tox.Length - 1 Console.WriteLine("{0},{1},{2}",x(i).name,x(i).phone,x(i).age) Next EndSub EndModule
דוגמא 12 –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 Fori = 0 Tox.Length - 1 If x(i).age < min Then min = x(i).age EndIf Next Console.WriteLine("youngest age is: " & min) EndSub
דוגמא 13 – מציאת ערך מינימלי והדפסת שדה אחר של בעל הערך ModuleModule1 StructureMember Dim name AsString Dim phone AsString Dim age AsInteger EndStructure Sub Main() Dim x(2) AsMember Fori = 0 Tox.Length - 1 x(i).name = Console.ReadLine() x(i).phone = Console.ReadLine() x(i).age = Console.ReadLine() Next המשך בשקף הבא...
דוגמא 13 – המשך Dimmin AsInteger = 120 Dim n AsString = "" Fori = 0 Tox.Length - 1 If x(i).age < min Then min = x(i).age n = x(i).name EndIf Next Console.WriteLine("name of youngest is: " & n) EndSub EndModule