1 / 24

CivTeam.wordpress

محاضرات في البرمجة. المحاضرة الثالثة. القسم العملي. للمزيد زورونا على موقعنا الإلكتروني:. CivTeam.wordpress.com. تعريف المصفوفات Arrays. Dim OneDim (9) As Integer ' 10 عناصر Dim TwoDims (1, 1) As String ' عناصر 4 = 2 * 2 OneDim (0) = 100 OneDim (1) = 200 … OneDim (9) = 900

ima
Download Presentation

CivTeam.wordpress

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. محاضرات في البرمجة المحاضرة الثالثة القسم العملي للمزيد زورونا على موقعنا الإلكتروني: CivTeam.wordpress.com

  2. تعريف المصفوفات Arrays Dim OneDim (9) As Integer ' 10 عناصر Dim TwoDims (1, 1) As String ' عناصر 4= 2 * 2 OneDim (0) = 100 OneDim (1) = 200 … OneDim (9) = 900 TwoDims (0, 0) = “Ahmad” TwoDims (0, 1) = “khaled” TwoDims (1, 0) = “Mouhamed” TwoDims (1, 1) = “Hassan”

  3. Imports system.console Module Module1 sub Main() Dim OneDim() As Integer = {1, 2, 3, 4, 5, 6, 7, 8, 9} Dim TwoDims(,) As String = {{“Saad" ,”George"} ,{”Lolo" ,”ٌReem"}} 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

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

  5. مسائل في البرمجة مسألة أكتب برنامجاً يقوم بقراءة ثلاثة أعداد {a1, a2, a3} و يحسب قيمة كل من المتوسط الحسابي و المدى لتلك الأعداد و يظهرهما على الشاشة

  6. مسائل في البرمجة Sub Main() Dim a(2), m, rng As Single Dim minv, maxv As Single Console.WriteLine("Enter the first number") a(0) = Console.ReadLine Console.WriteLine("Enter the second number") a(1) = Console.ReadLine Console.WriteLine("Enter the third number") a(2) = Console.ReadLine m = (a(0) + a(1) + a(2)) / 3

  7. مسائل في البرمجة If a(0) > a(1) And a(0) > a(2) Then maxv = a(0) ElseIf 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) ElseIf a(1) < a(0) And a(1) < a(2) Then minv = a(1) Else minv = a(2) End If

  8. مسائل في البرمجة rng = maxv - minv Console.WriteLine("The Avarage is: " & m) Console.WriteLine("The range is: " & rng) Console.WriteLine("Press any key to exit") Console.ReadLine() End Sub

  9. مسائل في البرمجة If a(1) > a(2) Then If a(3) > a(1) Then minv = a(2) : maxv = a(3) ElseIf 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) ElseIf a(3) < a(1) Then minv = a(3) : maxv = a(2) Else minv = a(1) : maxv = a(2) End If End If

  10. مسائل في البرمجة مسألة أكتب برنامجاً يقوم بقراءة مجموعة من الأعداد {a1, … an} عددها n و يحسب قيمة كل من المتوسط الحسابي و المدى لتلك الأعداد و يظهرهما على الشاشة

  11. مسائل في البرمجة Sub Main() Dim n As Int16 Dim a(), sum, m, rng As Single Console.WriteLine("Enter the number of the elements") n = Console.ReadLine ReDim a(n) Console.WriteLine("Enter the first number") a(0) = Console.ReadLine Dim minv As Single = a(0) Dim maxv As Single = a(0) sum = a(0) For i As Int16 = 1 To n-1 Console.WriteLine("Enter the next number") a(i) = Console.ReadLine 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.WriteLine("The Avarage is: " & m) Console.WriteLine("The range is: " & rng) Console.WriteLine("Press any key to exit") Console.ReadLine() End Sub

  12. مسائل في البرمجة مسألة أكتب برنامجاً يقوم بحساب البعد بين نقطتين و من ثم حساب ميل المستقيم المحدد بهما

  13. مسائل في البرمجة Imports System.Math Module Module1 Sub Main() strt: Dim st As String Dim x1, x2, y1, y2, dis, slope As Single Console.WriteLine("Enter x1") x1 = Console.ReadLine Console.WriteLine("Enter y1") y1 = Console.ReadLine Console.WriteLine("Enter x2") x2 = Console.ReadLine Console.WriteLine("Enter y2") y2 = Console.ReadLine dis = Sqrt((x1 - x2) ^ 2 + (y1 - y2) ^ 2)

  14. مسائل في البرمجة If dis > 0 Then If x1 <> x2 Then slope = (y1 - y2) / (x1 - x2) Console.WriteLine("Slpoe= " & slope) Else Console.WriteLine("Undefined slope") End If Else Console.WriteLine("You entered two congruant points") End If Console.WriteLine("Press x to exit or r to repeat the program with new points") st = Console.ReadLine If st = "r" Then GoTo strt ElseIf st = "x" Then Exit Sub End If End Sub End Module

  15. مسائل في البرمجة مسألة لدينا مصفوفة من الدرجة الثانية تحوي عدد من العناصر و قيمة ما نريد إخراج مصفوفة مماثلة في الأبعاد للمصفوفة الأصلية و تحوي واحدات في المواقع المقابلة لوجود القيمة المعطاة و أصفار في بقية المواقع

  16. مسائل في البرمجة Sub Main() Dim v As Single Dim b(,), e(,) As Single Dim n, m As Int16 Console.WriteLine("Enter the number of rows") m = Console.ReadLine Console.WriteLine("Enter the number of columns") n = Console.ReadLine ReDim b(m, n) : ReDim e(m, n)

  17. مسائل في البرمجة 'reading the data For i As Int16 = 1 To m For j As Int16 = 1 To n Console.WriteLine("Enter the element b(" & i & "," & j & ")") b(i, j) = Console.ReadLine Next Next Console.WriteLine("Enter the value you want to search for") v = Console.ReadLine

  18. مسائل في البرمجة 'searching for the value For i As Int16 = 1 To m For j As Int16 = 1 To n If b(i, j) = v Then e(i, j) = 1 Else e(i, j) = 0 End If Next Next

  19. مسائل في البرمجة 'printing the matrix e For i As Int16 = 1 To m For j As Int16 = 1 To n Console.WriteLine("e(" & i & "," & j & ")= " & e(i, j)) Next Next Console.WriteLine()

  20. مسائل في البرمجة 'another way to print the matrix e Dim ee As String Dim k, l As Int16 Console.WriteLine("e=") Console.WriteLine() For k = 1 To m ee = "" For l = 1 To n ee &= e(k, l) & " " Next Console.WriteLine(ee) Next Console.ReadLine() End Sub

  21. مسائل في البرمجة مسألة لدينا مجموعة نقط في المستوي n نقطة و مستقيم و المطلوب إيجاد بعد كل نقطة عن ذلك المستقيم

  22. مسائل في البرمجة Imports System.Console Imports System.Math Module Module1 Sub Main() str: Dim st As String Dim a, b, c As Single Dim p(,), d() As Single Dim n As Int16 WriteLine("Enter the number of points") n = ReadLine() ReDim p(n, 2) : ReDim d(n)

  23. مسائل في البرمجة WriteLine("Enter the constant a") a = ReadLine() WriteLine("Enter the constant b") b = ReadLine() WriteLine("Enter the constant c") c = ReadLine() If a = 0 And b = 0 Then WriteLine("No line with a=0 and b=0") ReadLine() Exit Sub End If

  24. مسائل في البرمجة For i As Int16 = 1 To n WriteLine("Enter x(" & i & ")") p(i, 1) = ReadLine() WriteLine("Enter y(" & i & ")") p(i, 2) = ReadLine() Next For i As Int16 = 1 To n d(i) = Abs(a * p(i, 1) + b * p(i, 2) + c) / Sqrt(a ^ 2 + b ^ 2) WriteLine("P(" & p(i, 1) & "," & p(i, 2) & ") -- distance= " & d(i)) Next WriteLine("Press 'r' to repeat") st = ReadLine() If st = "r" Then GoTo str End Sub End Module

More Related