Structure Structure Structure 1 2 End Structure Structure
- Slides: 22
Structure
Structure : סינטקס Structure שם המבנה 1 משתנה 2 משתנה . . . End Structure : דוגמא Structure Oved Dim name As String Dim maskoret As Integer End Structure
Structs (Structures) Module 1 Structure Oved Dim name As String Dim maskoret As Integer End Structure Sub Main() Dim x As Oved x. name = "Avi" x. maskoret = 1234 Dim People(10) As Oved People(0). name = "Yossi" People(1). name = "Moshe" People(2). name = "Lea" Console. Write. Line("People's Size is " & People. Length()) Console. Write. Line("The first name is " & People(0). name) Console. Write("The length of the first name is ") Console. Write. Line(People(0). name. Length()) End Sub End Module
Structure מערך של C++ Programming: From Problem Analysis to Program Design, Fifth Edition
דוגמא עם לולאות Module 1 Structure Oved Dim name As String Dim maskoret As Integer End Structure Sub Main() Dim People(10) As Oved Dim i As Integer For i = 0 To 2 Console. Write. Line("Please enter person number " & i) People(i). name = Console. Read. Line People(i). maskoret = Console. Read. Line() Next Dim min As Integer = People(0). maskoret Dim temp As String = People(0). name For i = 1 To 2 If (People(i). maskoret < min) Then min = People(i). maskoret temp = People(i). name End If Next Console. Write. Line("The min is " & min & " his name is " & temp) End Sub End Module
? מה ההבדל Module 1 Structure Oved Dim name As String Dim maskoret As Integer End Structure Sub Main() Dim People(10) As Oved Dim i As Integer For i = 0 To 2 Console. Write. Line("Please enter person number " & i) People(i). name = Console. Read. Line People(i). maskoret = Console. Read. Line() Next Dim min As Integer = 0 Dim temp As String = People(0). name For i = 1 To 2 If (People(i). maskoret < People(min). maskoret) Then min = i End If Next Console. Write. Line("The min is " & People(min). maskoret & " his name is " & People(min). name) End Sub End Module
. . . עם פונקציה Structure Oved Public name As String Public maskoret As Integer End Structure Sub Main() Dim People(5) As Oved Dim i As Integer For i = 0 To People. Length() - 1 Console. Write. Line("Please enter the person's name") People(i). name = Console. Read. Line Console. Write. Line("Please enter their maskoret") People(i). maskoret = Console. Read. Line Next Console. Write. Line("High " & Print. Highest(People)) End Sub
הפונקציה Function Print. Highest(By. Val x() As Oved) As Integer Dim i As Integer Dim high As Integer = x(0). maskoret For i = 0 To x. Length - 1 If x(i). maskoret > high Then high = x(i). maskoret End If Next Return high End Function
Module 1 Sub Main() Dim x As Oved x. name = "Avi" x. maskoret = 1234 Dim People(10) As Oved People(0). name = "Yossi" People(1). name = "Moshe" People(2). name = "Lea" Dim value As Integer = Print. Highest(People) Console. Write. Line("Highest is " & value) End Sub Structure Oved Public name As String Public maskoret As Integer End Structure Function Print. Highest(By. Val x() As Oved) As Integer Dim i As Integer Dim high As Integer = x(0). maskoret For i = 0 To x. Length - 1 If x(i). maskoret > high Then high = x(i). maskoret End If Next Return high End Function End Module ? מה יופיע פה
Module 1 Structure Shop Dim name As String Dim code As Integer Dim price As Double End Structure מימוש חנות Sub Main() Product 0 is: Cheese, its price is: 8. 75 Dim makolet(10) As Shop Product 1 is: Shnitzel, its price is: 21. 45 makolet(0). name = "Cheese" Product 2 is: Shoko, its price is: 4. 25 makolet(0). code = 111 Product 3 is: , its price is: 0 makolet(0). price = 8. 75 Product 4 is: , its price is: 0 makolet(1). name = "Shnitzel" Product 5 is: , its price is: 0 makolet(1). code = 222 Product 6 is: , its price is: 0 makolet(1). price = 21. 45 Product 7 is: , its price is: 0 makolet(2). name = "Shoko" Product 8 is: , its price is: 0 makolet(2). code = 122 Product 9 is: , its price is: 0 makolet(2). price = 4. 25 Product 10 is: , its price is: 0 Dim i As Integer For i = 0 To makolet. Length() - 1 Console. Write. Line("Product {0} is: {1}, its price is: {2}", i, makolet(i). name, makolet(i). price) Next End Sub End Module
Module 1 Structure Shop Dim name As String Dim code As Integer Dim price As Double End Structure Sub Main() Dim makolet(10) As Shop makolet(0). name = "Cheese" makolet(0). code = 111 makolet(0). price = 8. 75 makolet(1). name = "Shnitzel" Product 0 is: Cheese, its price is: 8. 75 makolet(1). code = 222 makolet(1). price = 21. 45 Product 1 is: Shnitzel, its price is: 21. 45 makolet(2). name = "Shoko" Product 2 is: Shoko, its price is: 4. 25 makolet(2). code = 122 makolet(2). price = 4. 25 Dim i As Integer For i = 0 To makolet. Length() - 1 If makolet(i). name <> Nothing Then Console. Write. Line("Product {0} is: {1}, its price is: {2}", i, makolet(i). name, makolet(i). price) End If Next End Sub End Module בלי הדפסת מוצרים ריקים
Module 1 Structure Shop Dim name As String Dim code As Integer Dim price As Double End Structure Sub Main() Dim makolet(10) As Shop makolet(0). name = "Cheese" makolet(0). code = 111 makolet(0). price = 8. 75 makolet(1). name = "Shnitzel" makolet(1). code = 222 makolet(1). price = 21. 45 makolet(2). name = "Shoko" makolet(2). code = 122 makolet(2). price = 4. 25 Print. Price(makolet) End Sub עם פונקציה Product 0 is: Cheese, its price is: 8. 75 Product 1 is: Shnitzel, its price is: 21. 45 Product 2 is: Shoko, its price is: 4. 25 Sub Print. Price(By. Val s() As Shop) Dim i As Integer For i = 0 To s. Length() - 1 If s(i). name <> Nothing Then Console. Write. Line("Product {0} is: {1}, its price is: {2}", i, s(i). name, s(i). price) End If Next End Sub End Module
: הקוד Sub Main() Dim makolet(10) As Shop makolet(0). name = "Cheese" makolet(0). code = 111 makolet(0). price = 8. 75 makolet(1). name = "Shnitzel" makolet(1). code = 222 makolet(1). price = 21. 45 Product 0 is: Cheese, its price is: 8. 75 Product 1 is: Shnitzel, its price is: 21. 45 The cheapest thing in makolet is Cheese Print. Price(makolet) Dim zol As String zol = Get. Zol(makolet) Console. Write. Line("The cheapest thing in makolet is " & zol) End Sub
Sub Main() Dim makolet(10) As Shop makolet(0). name = "Cheese" makolet(0). code = 111 makolet(0). price = 8. 75 makolet(1). name = "Shnitzel" makolet(1). code = 222 makolet(1). price = 21. 45 Dim bakery(10) As Shop bakery(0). name = "roll" bakery(0). code = 333 bakery(0). price = 6. 32 bakery(1). name = "pita" bakery(1). code = 777 bakery(1). price = 3. 6 ואם יש גם מכולת וגם ? מאפיה . . . נשתמש באותה פונקציה שוב ונקבל ממנה משהו אחר , נעביר לה פרמטר אחר Product 0 is: Cheese, its price is: 8. 75 Product 1 is: Shnitzel, its price is: 21. 45 The cheapest thing in makolet is Cheese Product 0 is: roll, its price is: 6. 32 Product 1 is: pita, its price is: 3. 6 The cheapest thing in bakery is pita Print. Price(makolet) Dim zol As String zol = Get. Zol(makolet) Console. Write. Line("The cheapest thing in makolet is " & zol) Print. Price(bakery) zol = Get. Zol(bakery) Console. Write. Line("The cheapest thing in bakery is " & zol) End Sub
Sub Main() Dim makolet(10) As Shop makolet(0). name = "Cheese" makolet(0). code = 111 makolet(0). price = 8. 75 makolet(1). name = "Shnitzel" makolet(1). code = 222 makolet(1). price = 21. 45 Dim bakery(10) As Shop bakery(0). name = "roll" bakery(0). code = 333 bakery(0). price = 6. 32 bakery(1). name = "pita" bakery(1). code = 777 bakery(1). price = 3. 6 Print. Price(makolet) Dim zol As String אפשר גם לשתול את מה שחוזר מהפונקציה ישר לתוך פקודת הדפסה Product 0 is: Cheese, its price is: 8. 75 Product 1 is: Shnitzel, its price is: 21. 45 The cheapest thing in makolet is Cheese Product 0 is: roll, its price is: 6. 32 Product 1 is: pita, its price is: 3. 6 The cheapest thing in bakery is pita Console. Write. Line("The cheapest thing in makolet is " & Get. Zol(makolet)) Print. Price(bakery) Console. Write. Line("The cheapest thing in makolet is " & Get. Zol(bakery)) End Sub
פונקציה לחישוב סכום המוצרים בסל Function Kupa(By. Val cart() As String, By. Val s() As Shop) As Single Dim total As Single = 0 For i = 0 To cart. Length - 1 For j = 0 To s. Length() - 1 If cart(i) = s(j). name Then total += s(j). price End If Next Return total End Function
Sub Main() Dim super(10) As Shop super(0). name = "Shoko" super(0). code = 111 super(0). price = 4. 75 super(1). name = "Apple" super(1). code = 222 super(1). price = 2. 45 Lunch costs 9. 8 shekel. super(2). name = "Bread" super(2). code = 333 super(2). price = 5. 05 super(3). name = "Bag" super(3). code = 444 super(3). price = 1. 2 Dim lunch() As String = {"Bread", "Shoko"} Console. Write. Line("Lunch costs " & Kupa(lunch, super) & " shekel. ") End Sub המשך חישוב סכום המוצרים בסל
- Stroke volume definition
- Ejection fraction vs stroke volume
- Explain compiler construction tools
- Back end compiler
- End zu end descendorektostomie
- End-to-end wireframe parsing
- End to end argument
- End to end accounting life cycle tasks
- End to end delay
- End to end delay
- End to end
- Comet commonsense
- End-to-end procurement life cycle
- Grade 10 accounting year-end adjustments
- Year 4 writing assessment task
- Font sans serif
- Diary writing about my birthday
- 2 chunk paragraph example
- What to do with remainders in division
- Closing remarks informal letter
- End plate potential
- End fed antenna length chart
- Volleyball canada scoresheet