מחרוזות של תווים. מבוא לתכנות למנע"ס - שבוע מספר 5 - מאיר קומר - סמסטר ב' - תשס"ו מחרוזות - Strings Dim s As String s = “hello” s = s & “kita” או s =

Slides:



Advertisements
Similar presentations
מבוא למדעי המחשב לתעשייה וניהול
Advertisements

מבוא למדעי המחשב לתעשייה וניהול דוגמאות ותרגול נוסף במערך חד ממדי הרצאה 12.
If – Case Programs CSC Arwa © 2008.
רשימה מקושרת Linked Lists. דוגמא STRING איך עושים Dim x as String בלי לדעת מראש את הגודל !
תכנות תרגול 9 שבוע : הקשר בין מערכים למצביעים נרצה לעמוד על הקשר בין מערך למצביע מאחר ומערכים הם הכללה של משתנים הרי שברור שלמערך ולכל אחד מאיבריו.
סוגי מידע / משתנים ד " ר אבי רוזנפלד. סוגאורךטווח Boolean1 Bit0,1 Byte1 byte0-255 Char 2 bytes תו Decimal16 bytes0 through +/-79,228,162,514,264,337,593,543,950,335.
11 Introduction to Programming in C תרגול
תכנות ב C#. דוגמא לפלט using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void.
תרגילים. גדול, קטן, וממוצע מקובץ Imports System.IO Module Module1 Sub Main() Dim readnum As StreamReader readnum = _ My.Computer.FileSystem.OpenTextFileReader.
אלגוריתמים, WINDOWS והחיים. מבוא למדעי המחשב - מאיר קומר - סמסטר א '- תשס " ט - שיעור מספר 7 מיוןsort.
מבני בקרה מבוא לתכנות למנע " ס - שבוע מספר 3 - מאיר קומר - סמסטר ב ' - תשס " ו הסתעפות “ אם השמאל ואימנה ואם הימין ואשמאילה ”
שימוש במערך דינמי : ArrayList. מאפיינים חשובים בכל LIST יכולת להכניס מידע בלי תלות בטיפוס יכולת למחוק מידע יכולת להוסיף מידע פונקציות נוספות ( מיון, חיפוש.
פתרון תרגיל 10. שאלה #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.
תכנות תרגול 10 שבוע : הקשר בין מערכים למצביעים נרצה לעמוד על הקשר בין מערך למצביע מאחר ומערכים הם הכללה של משתנים הרי שברור שלמערך ולכל אחד מאיבריו.
פתרון בוחן הכיתה. שאלה #1 Module Module1 Sub Main() Dim x, z As Integer x = Console.ReadLine() z = Console.ReadLine() If (x = 0) Then Console.WriteLine("Error")
פתרון תרגיל 11. שאלה #1 Module Module1 Sub Main() Dim x(10, 10) As Integer Dim i, j As Integer For i = 1 To 10 For j = 1 To 10 x(i, j) = i * j Console.Write("
מערכים מבוא לתכנות למנע"ס - שבוע מספר 8 - מאיר קומר - סמסטר ב' - תשס"ו והנה בעיה כתוב תוכנית אשר תקלוט 36 מספרים ותדפיס כמה מתוכם גדולים יותר מהממוצע.
נוצר ע " י ד " ר ארקדי שטיינבוק Visual Basic for Application VBA כדוגמה VBA ב - WORD.
מבני בקרה לולאות. פקודת CASE Module Module1 Sub Main() Dim input As Char input = Console.ReadLine() Select Case (input) Case "A" Console.WriteLine("A.
Selection Structures ; String Functions. If…Then…Else If condition Then [instructions when the condition is true] [Else [instructions when the condition.
Stacks and Queues. Stack ADT סוג של מערך מוגבל מהר מאוד ולוקחים מעט זכרון שימוש ב LIFO – LIFO (Last In, First Out) lists. –אפשר להוסיף רק בסוף הרשימה.
אלגוריתמי חיפוש. Brute Force Module Module1 Function BruteForce(ByRef x() As Integer, ByRef item As Integer) As Integer Dim i As Integer For i = 0 To.
פתרון תרגילים #9. דוגמה פשוטה #1 Module Module1 Sub Main() Dim x As String x = Console.ReadLine For i = 1 To x.Length() - 1 Step 2 Console.WriteLine(x(i))
מערכים דו ממדי ו STRUCTS פונקציות בוליאנית Module Module1 Function Flip(ByVal word1 As String) As Boolean Dim i As Integer For i = 0 To word1.Length()
פונקציות. פונקציות מוכרות Imports System.Math Module Module1 Sub Main() Dim x As Decimal = Math.Abs(-10.4) Dim y As Decimal Console.WriteLine("I will.
الحلقات for For i =1 To x step -2 …………. Next DO while (شرط) …………. Loop DO …………. Loop while (شرط) الحلقة Do while.
Structure. מה לומדים היום ? דרך לבנות מבנה נתונים בסיסי – Structure מייצר " טיפוס " חדש מתאים כאשר רוצים לאגד כמה משתנים יחד דוגמאות : עובד : שם, טלפון,
Inheritance Chapter 14. What is inheritance?  The ability to create a class from another class, the “parent” class, extending the functionality and state.
מבנה נתונים ואלגוריתמים ) לשעבר - עיבוד מידע( ד"ר אבי רוזנפלד ד"ר אריאלה ריכרדסון.
26/10/ Selection Nested If structures & Complex Multiple Conditions.
מבוא למדעי המחשב לתעשייה וניהול הרצאה 7. סברוטינות subroutines.
6c – Function Procedures Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
1 מבוא למחשב שפת C תרגילי חזרה. 2 תרגיל 1 : מחשבון קלט : תרגיל חשבוני המורכב ממספרים שלמים עם פעולות חשבוניות ביניהם. התרגיל מסתיים ב =. אפשריים רווחים.
Question 1a) What is printed by the following Java program? int s; int r; int i; int [] x = {4, 8, 2, -9, 6}; s = 1; r = 0; i = x.length - 1; while (i.
מחסנית ותור Stacks and Queues. מחסנית Stack מחסנית - Stack ADT סוג של מערך מוגבל מהיר מאוד ותופס מעט זיכרון שימוש ב LIFO – LIFO (Last In, First Out)
מבנה נתונים ואלגוריתמים ) לשעבר - עיבוד מידע( ד"ר אבי רוזנפלד ד"ר אריאלה ריכרדסון.
Other Variable Types Dim lab as String makes a box that can store a label tag Dim ColHead As String ColHead = “function” ColHead function Dim lab as Boolean.
COMPE 111 Introduction to Computer Engineering Programming in Python Atılım University
מבוא למדעי המחשב לתעשייה וניהול הרצאה 12. ספריות.
CECS 5020 Computers in Education Visual Basic Variables and Constants.
A: A: double “4” A: “34” 4.
Higher Computing Software Development -So Far- 5/10/10.
1 Microsoft® Visual Basic®.NET Language # 2. 2 Flow-Control Statements If … End If Select Case … End Select For… Next Do … Loop Exit.
מחסנית ותור Stacks and Queues. מחסנית Stack מחסנית - Stack ADT סוג של מערך מוגבל מהיר מאוד ותופס מעט זיכרון שימוש ב LIFO – LIFO (Last In, First Out)
DATA TYPES, VARIABLES AND CONSTANTS. LEARNING OBJECTIVES  Be able to identify and explain the difference between data and information  Be able to identify,
מבנה נתונים ואלגוריתמים ) לשעבר - עיבוד מידע( ד"ר אבי רוזנפלד ד"ר אריאלה ריכרדסון.
1 מבוא למדעי המחשב הרצאה 5: פונקציות. 2 מבוא לפונקציות חלוקה של אלגוריתם לתת משימות: משימה - פונקציה: דוגמאות מציאת המקסימלי מבין שני איברים האינדקס של.
Python Strings. String  A String is a sequence of characters  Access characters one at a time with a bracket operator and an offset index >>> fruit.
National Diploma Unit 4 Introduction to Software Development Procedures and Functions.
Visual Basic Declaring Variables Dim x as Integer = 0 In the statement above, x is being declared as an Integer (whole number) and is initialised.
אלגוריתמי חיפוש. Brute Force Module Module1 Function BruteForce(ByRef x() As Integer, ByRef item As Integer) As Integer Dim i As Integer For i = 0 To.
Java String Methods - Codehs
מבוא למדעי המחשב לתעשייה וניהול
Basic operators - strings
Method.
Compiler Design First Lecture.
Engineering Innovation Center
للمزيد زورونا على موقعنا الإلكتروني:
البرمجة بلغة الفيجول بيسك ستوديو
البرمجة بلغة فيجول بيسك ستوديو
מחסנית ותור Stacks and Queues.
Queues: Implemented using Arrays
Chapter 7: Using Functions, Subs, and Modules
Lesson Objectives Aims Key Words
Dictionary Builder Part 1 Getting Started.
VB.Net Programming Console Application
Basic Collections.
C# Revision Cards Data types
Question 1a) What is printed by the following Java program? int s;
COMPUTING.
Presentation transcript:

מחרוזות של תווים

מבוא לתכנות למנע"ס - שבוע מספר 5 - מאיר קומר - סמסטר ב' - תשס"ו מחרוזות - Strings Dim s As String s = “hello” s = s & “kita” או s = s + “kita” hellohellokita

מבוא לתכנות למנע"ס - שבוע מספר 5 - מאיר קומר - סמסטר ב' - תשס"ו מחזירה אורך המחרוזת Module Module1 Sub Main() Dim word As String word = Console.ReadLine Console.WriteLine(Len(word)) Console.WriteLine(word.Length()) End Sub End Module פעולות על מחרוזות Len 10

מבוא לתכנות למנע"ס - שבוע מספר 5 - מאיר קומר - סמסטר ב' - תשס"ו מחזירה תת - מחרוזת משמאל a = “hello kita” x = Left (a,2) פעולות על מחרוזות Left he כמה תוים איזה מחרוזת

מבוא לתכנות למנע"ס - שבוע מספר 5 - מאיר קומר - סמסטר ב' - תשס"ו מחזירה תת - מחרוזת מימין a = “hello kita” x = Right (a,6) פעולות על מחרוזות Right o kita כמה תוים איזה מחרוזת

מבוא לתכנות למנע"ס - שבוע מספר 5 - מאיר קומר - סמסטר ב' - תשס"ו מחזירה תת - מחרוזת a = “hello kita” x = Mid (a,2,3) פעולות על מחרוזות Mid ell כמה תוים החל מתו -

מבוא לתכנות למנע"ס - שבוע מספר 5 - מאיר קומר - סמסטר ב' - תשס"ו תרגול קטן Len (s) Left (s,6) Right (s,7) Mid (s,6,8) s = “arur haman baruch mordechai ” 27 arur h rdechai haman ba Mid (Right(s,9),2,3) ord Right (s,9) & Mid (s,11,7) mordechai baruch Left (s,10) = Mid (s,1,11)? לא

מבוא לתכנות למנע"ס - שבוע מספר 5 - מאיר קומר - סמסטר ב' - תשס"ו זה חוקי! "דוד" < "שלמה"?

דוגמא Module Module1 Sub Main() Dim word As String word = Console.ReadLine If (word > "avi") Then Console.WriteLine("Bigger") Else Console.WriteLine("Smaller") End If word = word + "A" Console.WriteLine(word) word = "B" & word Console.WriteLine(word) End Sub End Module

שימוש בסיסי במחרוזת Module Module1 Sub Main() Dim x As String x = Console.ReadLine Console.WriteLine("The Length is " & x.Length()) Console.WriteLine("The first letter is " & x(0)) Console.WriteLine("The second letter is " & x(1)) Console.WriteLine("The third letter is " & x(2)) Console.WriteLine("What will this do??? " & x(2000)) End Sub End Module

שימוש בסיסי במחרוזת Module Module1 Sub Main() Dim x As String x = Console.ReadLine Console.WriteLine("The first letter is " & x(0)) If (x(0) = "A") Then Console.WriteLine("Yeah!") End If If (x(1) = " ") Then Console.WriteLine("Space in second position") End If End Sub End Module

פעולות בסיסיות במחזרות Module Module1 Sub Main() Dim word As String word = Console.ReadLine 'word(0) = "B" ' Won't work! word = word.Replace("a", "b") 'word.Replace("a", "b") also won't work Console.WriteLine("The word now is " & word) word = word.Remove(0, 2) 'takes out first 2 letters Console.WriteLine("The word now is " & word) word = word.Insert(0, "B2") 'add string at position Console.WriteLine("The word now is " & word) End Sub End Module

דוגמא של לולאה במחרוזת Module Module1 Sub Main() Dim x As String Dim i, j As Integer x = Console.ReadLine Console.WriteLine("The Length is " & x.Length()) For i = 0 To x.Length() - 1 For j = 0 To i Console.Write(x(j)) Next Console.WriteLine() Next End Sub End Module

פונקציות עם מחרוזות Module Module1 Function Length(ByVal x As String) As Integer Return x.Length() End Function Sub Main() Dim x As String x = Console.ReadLine Dim y As Integer = Length(x) Console.WriteLine("The length was " & y) End Sub End ModuleA

פונקציה יותר מסובכת Module Module1 Function Change(ByVal x As String) As String Dim i As Integer For i = 0 To x.Length() - 1 If x(i) = "a" Or x(i) = "e" Or x(i) = "i" Then x = x.Remove(i, 1) 'Takes out that letter Console.WriteLine("The word is now " & x) x = x.Insert(i, "Z") 'Puts something else there End If Next Return x End Function Sub Main() Dim word As String word = Console.ReadLine Console.WriteLine("The Word is " & Change(word)) End Sub End Module

פונקציה יותר מסובכת עם REF Module Module1 Sub Change(ByRef x As String) Dim i As Integer For i = 0 To x.Length() - 1 If x(i) = "a" Or x(i) = "e" Or x(i) = "i" Then x = x.Remove(i, 1) 'Takes out that letter Console.WriteLine("The word is now " & x) x = x.Insert(i, "Z") 'Puts something else there End If Next End Sub Sub Main() Dim word As String word = Console.ReadLine Change(word) Console.WriteLine("The Word is " & word) End Sub End Module

פונקציות בוליאנית Module Module1 Function Compare(ByVal word1 As String, ByVal word2 As String) As Boolean Dim i As Integer If (word1.Length <> word2.Length) Then Return False Else For i = 0 To word1.Length() - 1 If word1(i) <> word2(i) Then Return False End If Next End If Return True End Function Sub Main() Dim a, b As String a = Console.ReadLine b = Console.ReadLine If (a = b) Then Console.WriteLine("They are the same") End If If (Compare(a, b)) Then Console.WriteLine("They are still the same") End If End Sub End Module

פונקציות בוליאנית Module Module1 Function Flip(ByVal word1 As String) As Boolean Dim i As Integer For i = 0 To word1.Length() - 1 If word1(i) <> word1(word1.Length() i) Then Return False End If Next Return True End Function Sub Main() Dim a, b As String a = Console.ReadLine If (Flip(a)) Then Console.WriteLine("It is a palindrome") Else Console.WriteLine("It isn't") End If End Sub End Module