Download presentation
Presentation is loading. Please wait.
1
פתרון תרגיל 10
2
שאלה #1 Module Module1 Sub Main() Dim maarach(9), zoogy(4), ezoogy(5) As Integer Dim i, counter, j As Integer For i = 0 To 9 Console.WriteLine("please enter a number") maarach(i) = Console.ReadLine() Next counter = 0 For i = 0 To 4 ezoogy(i) = maarach(counter) Console.Write(ezoogy(i) & ",") counter += 2 Next Console.WriteLine() counter = 1 For j = 1 To 5 zoogy(i) = maarach(counter) Console.Write(zoogy(i) & ",") counter += 2 Next Console.ReadKey() End Sub End Module
3
שאלה #1 Module Module1 Sub Main() Dim x(9), z(4), ez(4) As Integer Dim i As Integer For i = 0 To 9 x(i) = Console.ReadLine() Next For i = 0 To 9 Step 2 z(i / 2) = x(i) ez(i / 2) = x(i + 1) Console.Write(z(i / 2)) Next For i = 0 To 4 Console.Write(ez(i)) Console.Write(z(i)) Next Console.ReadKey() End Sub End Module
4
שאלה #2 Module Module1 Sub Main() Dim a(10) As String Dim x, b(10) As Integer For x = 0 To 9 a(x) = Console.ReadLine Next For x = 0 To 9 b(x) = a(x).Length() Console.Write(b(x) & ",") Next Console.ReadKey() End Sub End Module
5
שאלה #2 Module Module1 Sub Main() Dim arr1() As String = {} Dim arr2() As Integer = {} Dim answer As String = "y" While (answer = "y") Console.WriteLine("Do you want another string? y\n? ") answer = Console.ReadLine() If (answer = "y") Then Array.Resize(arr1, arr1.Length + 1) Console.WriteLine("write the string ") arr1(arr1.Length - 1) = Console.ReadLine() End If End While Dim i As Integer For i = 0 To arr1.Length - 1 Array.Resize(arr2, arr2.Length + 1) arr2(i) = Len(arr1(i)) Console.Write(arr2(i) & ", ") Next End Sub End Module
6
שאלה #3 Module Module1 Function Min(ByVal x() As Decimal) Dim i, k As Decimal k = x(0) For i = 1 To 10 If x(i) < k Then k = x(i) End If Next Return k End Function Sub Main() Dim x, a(10) As Decimal Console.WriteLine("na lirsom misparim lamarach") For x = 0 To 10 a(x) = Console.ReadLine Next Console.WriteLine("amispar akatan beyoter: " & Min(a)) End Sub End Module
7
שאלה #4 Module Module1 Sub PrintAtzeret(ByVal x() As Integer) Dim i, j, k As Integer k = 1 For i = 0 To 10 For j = 1 To x(i) k = k * j Next Console.WriteLine("azeret sel " & x(i) & ": " & k) k = 1 Next End Sub Sub Main() Dim x, a(10) As Integer Console.WriteLine("na lirsom misparim lamarach") For x = 0 To 10 a(x) = Console.ReadLine Next PrintAtzeret(a) End Sub End Module
8
שאלה #4 Module Module1 Function Atzeret(ByVal x As Integer) Dim answer As Integer = 1 Dim i As Integer For i = 2 To x answer *= i Next Return answer End Function Sub PrintAtzeret(ByVal x() As Integer) Dim j As Integer For j = 0 To x.Length() - 1 Console.WriteLine("azeret sel " & x(j) & ": " & Atzeret(x(j))) Next End Sub Sub Main() Dim x, a(10) As Integer Console.WriteLine("na lirsom misparim lamarach") For x = 0 To 10 a(x) = Console.ReadLine Next PrintAtzeret(a) End Sub End Module
9
שאלה #5 Module Module1 Function Compare(ByVal x() As Integer, ByVal y() As Integer) As Boolean Dim i As Integer For i = 0 To 10 If x(i) <> y(i) Then Return False End If Next Return True End Function Sub Main() Dim x, y, i, a(10), b(10) As Integer y = 0 Console.WriteLine("na lirsom misparim lamarach") For x = 0 To 10 a(x) = Console.ReadLine Next For i = 10 To 0 Step -1 b(i) = a(y) y += 1 Next Console.WriteLine("simetriut: " & Compare(a, b)) End Sub End Module
10
שאלה #5 Module Module1 Function Compare(ByVal x() As Integer) As Boolean Dim i As Integer For i = 0 To x.Length - 1 If x(i) <> x(x.Length() - 1 - i) Then Return False End If Next Return True End Function Sub Main() Dim x() As Integer = {1, 2, 3, 4, 3, 2, 1} If (Compare(x)) Then Console.WriteLine("The array is symmetrical.") Else Console.WriteLine("The array is not symmetrical.") End If Console.ReadKey() End Sub End Module
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.