פתרון תרגיל 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("

Slides:



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

If – Case Programs CSC Arwa © 2008.
סוגי מידע / משתנים ד " ר אבי רוזנפלד. סוגאורךטווח Boolean1 Bit0,1 Byte1 byte0-255 Char 2 bytes תו Decimal16 bytes0 through +/-79,228,162,514,264,337,593,543,950,335.
תרגילים. גדול, קטן, וממוצע מקובץ Imports System.IO Module Module1 Sub Main() Dim readnum As StreamReader readnum = _ My.Computer.FileSystem.OpenTextFileReader.
מבני בקרה מבוא לתכנות למנע " ס - שבוע מספר 3 - מאיר קומר - סמסטר ב ' - תשס " ו הסתעפות “ אם השמאל ואימנה ואם הימין ואשמאילה ”
פתרון תרגיל 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.
פתרון בוחן הכיתה. שאלה #1 Module Module1 Sub Main() Dim x, z As Integer x = Console.ReadLine() z = Console.ReadLine() If (x = 0) Then Console.WriteLine("Error")
מערכים מבוא לתכנות למנע"ס - שבוע מספר 8 - מאיר קומר - סמסטר ב' - תשס"ו והנה בעיה כתוב תוכנית אשר תקלוט 36 מספרים ותדפיס כמה מתוכם גדולים יותר מהממוצע.
מבני בקרה לולאות. פקודת CASE Module Module1 Sub Main() Dim input As Char input = Console.ReadLine() Select Case (input) Case "A" Console.WriteLine("A.
Chapter seven review. What is the output of: Private Sub cmdButton_Click() Dim i As Integer, a(1 To 4) As integer Open "DATA.TXT" For Input As #1 For.
תרגיל #3 פתרונות. חלק א ' ה STRUCT Structure COURSES Dim semkors, semmarza As String Dim kodkors, mispartalmidim, zionminimali As Integer End Structure.
פתרון תרגילים #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()
Arrays. What is the output of: Private Sub cmdButton_Click() Dim i As Integer, a(1 To 4) As integer Open "DATA.TXT" For Input As #1 For i = 1 To 4 Input.
פונקציות. פונקציות מוכרות 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.
1 INF110 Visual Basic Programming AUBG Spring semester 2011 Reference books: Schneider D., An Introduction to Programming Using Visual Basic, Prentice.
1. 2 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Decisions { class.
1.3 Console Input And Output academy.zariba.com 1.
1 2.2 Selection Logical Operators. 2 Learning Objectives Explain how the logical operator AND Boolean statements works.
 2002 Prentice Hall. All rights reserved. 1 Chapter 4: Control Structures: Part 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures.
26/10/ Selection Nested If structures & Complex Multiple Conditions.
Chapter 5: Control Structures: Iteration Visual Basic.NET Programming: From Problem Analysis to Program Design.
1 Chapter 10 Additional Control Structures and Exceptions.
Count and add list of numbers From user input and from file.
מבוא למדעי המחשב לתעשייה וניהול הרצאה 7. סברוטינות subroutines.
Chapter 5: Control Structures: Iteration Visual Basic.NET Programming: From Problem Analysis to Program Design.
مسألة أكتب برنامجاً يقوم بقراءة عددين و إظهار رسالة تفيد بأن أحد العددين هو المضاعف النوني للعدد الآخر و في حال عدم كون أي من العددين مضاعفاً للآخر يظهر.
מבוא למדעי המחשב לתעשייה וניהול הרצאה 12. ספריות.
Chapter One Lesson Three DATA TYPES ©
A: A: double “4” A: “34” 4.
5.1 Introduction Problem Solving –Requires understanding of: Building blocks Program-construction principles BZUPAGES.COM.
05/02/ Records. 205/02/2016 Learning Objectives State: The difference between records and arrays. The difference between records and arrays. How.
DATA TYPES, VARIABLES AND CONSTANTS. LEARNING OBJECTIVES  Be able to identify and explain the difference between data and information  Be able to identify,
Sum of Arithmetic Sequences. Definitions Sequence Series.
מבנה נתונים ואלגוריתמים ) לשעבר - עיבוד מידע( ד"ר אבי רוזנפלד ד"ר אריאלה ריכרדסון.
 2002 Prentice Hall. All rights reserved. 1 Chapter 5 – Control Structures: Part 2 Outline 5.1Introduction 5.2 Essentials of Counter-Controlled Repetition.
情報基礎 A Lecture 12 Takeshi Tokuyama Tohoku University Graduate School of Information Sciences System Information Sciences Design and Analysis of Information.
Subroutines and Functions Chapter 6. Introduction So far, all of the code you have written has been inside a single procedure. –Fine for small programs,
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.
מבוא למדעי המחשב לתעשייה וניהול
Basics programming concepts-2
الاسباب الأضرار وسائل الحمايه
للمزيد زورونا على موقعنا الإلكتروني:
Review Operation Bingo
مراجعة الحاسب.
البرمجة بلغة الفيجول بيسك ستوديو
البرمجة بلغة فيجول بيسك ستوديو
Variables, Loops, Decision Statements, etc
C# Control Statements part 1 (Based on Deitel Book)
ניתוח מערכות מידע תכנות ב C#
מבוא למדעי המחשב לתעשייה וניהול
المحاضرة السادسة.
kbkjlj/m/lkiubljj'pl;
VB.Net Programming Console Application
VB.Net Programming Console Application
Console.WriteLine(“Good luck!”);
1D Arrays and Lots of Brackets
CSE Module 1 A Programming Primer
Lesson Objectives Aims Key Words
Var Name =Console . ReadLine();
VB.Net Programming Console Application
C# Revision Cards Data types
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Data Types and Maths Programming Guides.
GCSE Computing:: Selection (IF statements)
Arrays Wellesley College CS230 Lecture 02 Thursday, February 1
Name of Pupil: Your Name Here
Chapter 3 String manipulation.
Presentation transcript:

פתרון תרגיל 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(" " & x(i, j)) Next Console.WriteLine() Next Console.ReadKey() End Sub End Module

שאלה #2 Module Module1 Sub Main() Dim x(3, 3) As Integer Dim i, j As Integer Dim num As New Random() Dim sum As Integer = 0 For i = 0 To 3 For j = 0 To 3 x(i, j) = num.Next(8, 14) If i = j Or (i + j) = 3 Then sum += x(i, j) End If Next Console.WriteLine("the sum is: " & sum) Console.ReadKey() End Sub End Module

שאלה #2 (כמעט זהה) Module Module1 Sub Main() Dim a(3, 3) As Integer Dim i, j, sam As Integer Dim num As New Random() sam = 0 For i = 0 To 3 For j = 0 To 3 a(i, j) = num.Next(8, 13) If i = j Then sam = sam + a(i, j) ElseIf i + j = 3 Then sam = sam + a(i, j) End If Next Console.WriteLine(sam) Console.ReadKey() End Sub End Module

שאלה 2 (איך שאני הייתי עושה) Module Module1 Sub Main() Dim sum1, sum2, i, j, x(3, 3) As Integer Dim r As New Random sum1 = 0 sum2 = 0 For i = 0 To 3 For j = 0 To 3 x(i, j) = r.Next(8, 13) Console.Write(x(i, j) & ",") Next Console.WriteLine() Next j = 4 For i = 0 To 3 sum1 += x(i, i) sum2 += x(i, j – i) Next Console.WriteLine("the sum is: " & sum1 + sum2) End Sub End Module

שאלה #3 Module Module1 Sub Main() Dim i, j, x(10, 5), y(10, 5) As Integer Dim r As New Random Dim b As Boolean b = True For i = 0 To 9 For j = 0 To 4 x(i, j) = r.Next(8, 18) y(i, j) = r.Next(3, 13) If x(i, j) <= y(i, j) Then b = False End If Next If b = True Then Console.WriteLine("yes") End If Console.ReadKey() End Sub End Module

פתרון יותר טוב? Module Module1 Sub Main() Dim a(4, 9), b(4, 9) As Integer Dim i, j, sam As Integer Dim num As New Random() sam = 0 For i = 0 To 4 For j = 0 To 9 a(i, j) = num.Next(8, 18) b(i, j) = num.Next(3, 13) If a(i, j) > b(i, j) Then sam = sam + 1 End If Next If sam = 50 Then Console.WriteLine("yes") End If Console.ReadKey() End Sub End Module

שאלה #4 Module Module1 Structure student Public name As String Public i_d As String Public average As Decimal End Structure Sub Main() Dim Pupile(4) As student Dim i As Integer Dim biggest As Decimal For i = 0 To 4 Console.WriteLine("please enter a name") Pupile(i).name = Console.ReadLine() Console.WriteLine("please enter an i d number") Pupile(i).i_d = Console.ReadLine() Console.WriteLine("please enter an average number") Pupile(i).average = Console.ReadLine() Next i = 0 biggest = Pupile(0).average For i = 0 To 4 If Pupile(i).average > biggest Then biggest = Pupile(i).average End If Next i = 0 For i = 0 To 4 If biggest = Pupile(i).average Then Console.WriteLine("the name of the student is: " & Pupile(i).name) End If Next Console.ReadKey() End Sub End Module

שאלה #4 Module Module1 Structure student Public name As String Public tz, memoza As Integer End Structure Sub Main() Dim sham(5) As student Dim i, j As Integer Dim n As String n = " " j = 0 For i = 1 To 5 Console.WriteLine("please enter the student name " & i) sham(i).name = Console.ReadLine Console.WriteLine("please enter the student i.d " & i) sham(i).tz = Console.ReadLine Console.WriteLine("please enter the student avrage " & i) sham(i).memoza = Console.ReadLine If sham(i).memoza > j Then j = sham(i).memoza n = sham(i).name End If Next Console.WriteLine("name: " & n & " tsiun is :" & j) Console.ReadKey() End Sub End Module