Arrays Dim One Dim 9 As Integer 10
























- Slides: 24


Arrays ﺗﻌﺮﻳﻒ ﺍﻟﻤﺼﻔﻮﻓﺎﺕ Dim One. Dim (9) As Integer ' 10 ﻋﻨﺎﺻﺮ Dim Two. Dims (1, 1) As String ' 2 * 2 =4 ﻋﻨﺎﺻﺮ One. Dim (0) = 100 One. Dim (1) = 200 … One. Dim (9) = 900 Two. Dims (0, 0) = “Ahmad” Two. Dims (0, 1) = “khaled” Two. Dims (1, 0) = “Mouhamed” Two. Dims (1, 1) = “Hassan”

Imports system. console Module 1 sub Main() Dim One. Dim() As Integer = {1, 2, 3, 4, 5, 6, 7, 8, 9} Dim Two. Dims(, ) As String = {{“Saad" , ”George"} , {”Lol Dim test(, ) as Integer = {{1, 2, 3}, {4, 5, 6}} Writeline(test(0, 0)) Writeline(test(0, 1)) Writeline(test(0, 2)) Writeline(test(1, 0)) Writeline(test(1, 1)) Writeline(test(1, 2)) Readline() End sub Reem"}}

Imports System. Console Module 1 Sub Main() Dim liste() As String = {"Rami", "Sami", "Keis", "Lina", "Linda"} Dim points() As Integer = {70, 65, 66, 50, 55} Write. Line(liste. Length) Write. Line(liste. Rank) Write. Line(liste(0)) Write. Line(liste(2) & " : " & points(2)) Read. Line() End Sub End Module


ﻣﺴﺎﺋﻞ ﻓﻲ ﺍﻟﺒﺮﻣﺠﺔ Sub Main() Dim a(2), m, rng As Single Dim minv, maxv As Single Console. Write. Line("Enter the first number") a(0) = Console. Read. Line Console. Write. Line("Enter the second number") a(1) = Console. Read. Line Console. Write. Line("Enter the third number") a(2) = Console. Read. Line m = (a(0) + a(1) + a(2)) / 3

ﻣﺴﺎﺋﻞ ﻓﻲ ﺍﻟﺒﺮﻣﺠﺔ If a(0) > a(1) And a(0) > a(2) Then maxv = a(0) Else. If a(1) > a(0) And a(1) > a(2) Then maxv = a(1) Else maxv = a(2) End If If a(0) < a(1) And a(0) < a(2) Then minv = a(0) Else. If a(1) < a(0) And a(1) < a(2) Then minv = a(1) Else minv = a(2) End If

ﻣﺴﺎﺋﻞ ﻓﻲ ﺍﻟﺒﺮﻣﺠﺔ rng = maxv - minv Console. Write. Line("The Avarage is: " & m) Console. Write. Line("The range is: " & rng) Console. Write. Line("Press any key to exit") Console. Read. Line() End Sub

ﻣﺴﺎﺋﻞ ﻓﻲ ﺍﻟﺒﺮﻣﺠﺔ If a(1) > a(2) Then If a(3) > a(1) Then minv = a(2) : maxv = a(3) Else. If a(3) < a(2) Then minv = a(3) : maxv = a(1) Else minv = a(2) : maxv = a(1) End If Else If a(3) > a(2) Then minv = a(1) : maxv = a(3) Else. If a(3) < a(1) Then minv = a(3) : maxv = a(2) Else minv = a(1) : maxv = a(2) End If


ﻣﺴﺎﺋﻞ ﻓﻲ ﺍﻟﺒﺮﻣﺠﺔ Sub Main() Dim n As Int 16 Dim a(), sum, m, rng As Single Console. Write. Line("Enter the number of the elements") n = Console. Read. Line Re. Dim a(n) Console. Write. Line("Enter the first number") a(0) = Console. Read. Line Dim minv As Single = a(0) Dim maxv As Single = a(0) sum = a(0) For i As Int 16 = 1 To n-1 Console. Write. Line("Enter the next number") a(i) = Console. Read. Line sum += a(i) If a(i) < minv Then minv = a(i) If a(i) > maxv Then maxv = a(i) Next m = sum / n rng = maxv - minv Console. Write. Line("The Avarage is: " & m) Console. Write. Line("The range is: " & rng) Console. Write. Line("Press any key to exit") Console. Read. Line() End Sub


ﻣﺴﺎﺋﻞ ﻓﻲ ﺍﻟﺒﺮﻣﺠﺔ Imports System. Math Module 1 Sub Main() strt: Dim st As String Dim x 1, x 2, y 1, y 2, dis, slope As Single Console. Write. Line("Enter x 1") x 1 = Console. Read. Line Console. Write. Line("Enter y 1") y 1 = Console. Read. Line Console. Write. Line("Enter x 2") x 2 = Console. Read. Line Console. Write. Line("Enter y 2") y 2 = Console. Read. Line dis = Sqrt((x 1 - x 2) ^ 2 + (y 1 - y 2) ^ 2)

ﻣﺴﺎﺋﻞ ﻓﻲ ﺍﻟﺒﺮﻣﺠﺔ If dis > 0 Then If x 1 <> x 2 Then slope = (y 1 - y 2) / (x 1 - x 2) Console. Write. Line("Slpoe= " & slope) Else Console. Write. Line("Undefined slope") End If Else Console. Write. Line("You entered two congruant points") End If Console. Write. Line("Press x to exit or r to repeat the program with new points") st = Console. Read. Line If st = "r" Then Go. To strt Else. If st = "x" Then Exit Sub End If End Sub End Module


ﻣﺴﺎﺋﻞ ﻓﻲ ﺍﻟﺒﺮﻣﺠﺔ Sub Main() Dim v As Single Dim b(, ), e(, ) As Single Dim n, m As Int 16 Console. Write. Line("Enter the number of rows") m = Console. Read. Line Console. Write. Line("Enter the number of columns") n = Console. Read. Line Re. Dim b(m, n) : Re. Dim e(m, n)

ﻣﺴﺎﺋﻞ ﻓﻲ ﺍﻟﺒﺮﻣﺠﺔ 'reading the data For i As Int 16 = 1 To m For j As Int 16 = 1 To n Console. Write. Line("Enter the element b(" & i & ", " & j & ")") b(i, j) = Console. Read. Line Next Console. Write. Line("Enter the value you want to search for") v = Console. Read. Line

ﻣﺴﺎﺋﻞ ﻓﻲ ﺍﻟﺒﺮﻣﺠﺔ 'searching for the value For i As Int 16 = 1 To m For j As Int 16 = 1 To n If b(i, j) = v Then e(i, j) = 1 Else e(i, j) = 0 End If Next

ﻣﺴﺎﺋﻞ ﻓﻲ ﺍﻟﺒﺮﻣﺠﺔ 'printing the matrix e For i As Int 16 = 1 To m For j As Int 16 = 1 To n Console. Write. Line("e(" & i & ", " & j & ")= " & e(i, j)) Next Console. Write. Line()

ﻣﺴﺎﺋﻞ ﻓﻲ ﺍﻟﺒﺮﻣﺠﺔ 'another way to print the matrix e Dim ee As String Dim k, l As Int 16 Console. Write. Line("e=") Console. Write. Line() For k = 1 To m ee = "" For l = 1 To n ee &= e(k, l) & " " Next Console. Write. Line(ee) Next Console. Read. Line() End Sub


ﻣﺴﺎﺋﻞ ﻓﻲ ﺍﻟﺒﺮﻣﺠﺔ Imports System. Console Imports System. Math Module 1 Sub Main() str: Dim st As String Dim a, b, c As Single Dim p(, ), d() As Single Dim n As Int 16 Write. Line("Enter the number of points") n = Read. Line() Re. Dim p(n, 2) : Re. Dim d(n)

ﻣﺴﺎﺋﻞ ﻓﻲ ﺍﻟﺒﺮﻣﺠﺔ Write. Line("Enter the constant a") a = Read. Line() Write. Line("Enter the constant b") b = Read. Line() Write. Line("Enter the constant c") c = Read. Line() If a = 0 And b = 0 Then Write. Line("No line with a=0 and b=0") Read. Line() Exit Sub End If

ﻣﺴﺎﺋﻞ ﻓﻲ ﺍﻟﺒﺮﻣﺠﺔ For i As Int 16 = 1 To n Write. Line("Enter x(" & i & ")") p(i, 1) = Read. Line() Write. Line("Enter y(" & i & ")") p(i, 2) = Read. Line() Next For i As Int 16 = 1 To n d(i) = Abs(a * p(i, 1) + b * p(i, 2) + c) / Sqrt(a ^ 2 + b ^ 2) Write. Line("P(" & p(i, 1) & ", " & p(i, 2) & ") -- distance= " & d(i)) Next Write. Line("Press 'r' to repeat") st = Read. Line() If st = "r" Then Go. To str End Sub End Module