Algorithms. Algorithm (1) Read 8-digit integers from a file to an array Verify which of these numbers are real dates, which are not Don’t forget leap.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

The Binary Numbering Systems
Introduction to C Programming
Lecture # 02 07/02/2013Dr. Muhammad Umair 1. 07/02/2013Dr. Muhammad Umair 2  Numeric  Integer Numbers  0,10,15,4563 etc.  Fractional Number  10.5,
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
Connecting with Computer Science, 2e
Level ISA3: Information Representation
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
CS 206 Introduction to Computer Science II 03 / 16 / 2009 Instructor: Michael Eckmann.
Chapter 8 Arrays and Strings
Introduction to C Programming
CS 206 Introduction to Computer Science II 10 / 28 / 2009 Instructor: Michael Eckmann.
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
Number Systems and Codes In PLC
Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn.
Objectives You should be able to describe: Data Types
Programmable Logic Controllers
Fortran 1- Basics Chapters 1-2 in your Fortran book.
Click to edit Master title style Click to edit Master text styles –Second level Third level –Fourth level »Fifth level 1 Today’s Topics How information.
 Pearson Education, Inc. All rights reserved Formatted Output.
 2005 Pearson Education, Inc. All rights reserved Formatted Output.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 14 Introduction to Computer Graphics.
Shawlands Academy Higher Computing Data Representation.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
STRING Dong-Chul Kim BioMeCIS UTA 10/7/
C Tokens Identifiers Keywords Constants Operators Special symbols.
STREAMS AND FILES OVERVIEW.  Many programs are "data processing" applications  Read the input data  Perform sequence of operations on this data  Write.
Characters The data type char represents a single character in Java. –Character values are written as a symbol: ‘a’, ‘)’, ‘%’, ‘A’, etc. –A char value.
CS1 Lesson 2 Introduction to C++ CS1 Lesson 2 -- John Cole1.
Chapter 8 Arrays and Strings
Number System. Number Systems Important Number systems – Decimal – Binary – Hexadecimal.
CPS120: Introduction to Computer Science Computer Math: Converting to Decimal.
Topic 1 – Number Systems. What is a Number System? A number system consists of an ordered set of symbols (digits) with relations defined for addition,
Fundamentals of Python: First Programs
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Arrays.
CISC1100: Binary Numbers Fall 2014, Dr. Zhang 1. Numeral System 2  A way for expressing numbers, using symbols in a consistent manner.  " 11 " can be.
ENG College of Engineering Engineering Education Innovation Center 1 Array Accessing and Strings in MATLAB Topics Covered: 1.Array addressing. 2.
Introduction to Database using Microsoft Access 2013 Part 6.1 November 18, 2014.
Relational Databases. Relational database  data stored in tables  must put data into the correct tables  define relationship between tables  primary.
CPS120: Introduction to Computer Science Lecture 15 Arrays.
Using Text Files in Excel File I/O Methods. Working With Text Files A file can be accessed in any of three ways: –Sequential access: By far the most common.
Data as the computer sees it 1.  Number systems Number systems  Data storage Data storage  Glossary Glossary 2.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
C++ Programming Lecture 3 C++ Basics – Part I The Hashemite University Computer Engineering Department (Adapted from the textbook slides)
Data Representation. What is data? Data is information that has been translated into a form that is more convenient to process As information take different.
Introduction to Engineering MATLAB – 4 Arrays Agenda Creating arrays of numbers  Vectors: 1-D Arrays  Arrays: 2-D Arrays Array Addressing Strings & String.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
Chapter 8 Arrays. A First Book of ANSI C, Fourth Edition2 Introduction Atomic variable: variable whose value cannot be further subdivided into a built-in.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Student Grades Application Introducing Two-Dimensional Arrays and RadioButton.
A FIRST BOOK OF C++ CHAPTER 14 THE STRING CLASS AND EXCEPTION HANDLING.
Microsoft Access Prepared by the Academic Faculty Members of IT.
Week 7 : String and photo processing. Today’s Tasks  Practice list and string  Convert Decimal to any radix base number  Between Binary and Hexadecimal.
What is Binary Code? Computers use a special code of their own to express the digital information they process. It's called the binary code because it.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Computer Hardware & Operation Northern College Diploma Philip Bird.
DATA Unit 2 Topic 2. Different Types of Data ASCII code: ASCII - The American Standard Code for Information Interchange is a standard seven-bit code that.
© 2016 Pearson Education, Ltd. All rights reserved.
Other Kinds of Arrays Chapter 11
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Python I/O.
Decimal System The radix or base of a number system determines
Introduction to C++ Programming
WEB PROGRAMMING JavaScript.
Fundamentals of Python: First Programs
Data Representation and Organization
Arrays.
Lexical Elements & Operators
Networks & I/O Devices.
Presentation transcript:

Algorithms

Algorithm (1) Read 8-digit integers from a file to an array Verify which of these numbers are real dates, which are not Don’t forget leap year! E.g , , , etc 20152

Algorithm (2) Client wishes to withdraw cash from an ATM The ATM gives the client the specified amount of cash, moreover, it will give the least amount of bills possible Currency will be Euro banknotes. Verify, that it’s possible to withdraw the sum specified by the client. E.g.537€ - Error (no 2-euro banknote) 195€ -1x100€ + 1x50€ + 2x20€ + 1x5€ 20153

Algorithm (3) Cargo is being brought to an intermediary storage from 2 storage complexes before shipping out from there. For storage complexes, use 2 arrays A and B as integer arrays for the weight of the cargo units. Cargo must exit the intermediary storage heavier units first. E.g. Storage A: 7, 59, 1, 93, 15, 27, 48, 6 Storage B: 9, 3, 1, 94 Exit order from intermediary: 94, 93, 59, 48, 27, 15, 9, 7, 6, 3, 1,

Algorithm (4) User inputs 4-character words as strings Check, which of those numbers are definitely hexadecimal, which binary and which don’t belong to either. Assume, that hexadecimal numbers include at least one digit higher than ‘1’ E.g. 0110, AZY1, 001F, 0101, 0Y24 etc 20155

Algorithm (5) Text is read from a file Find the frequency of characters in the text Lower- and uppercase characters are treated as the same Words are separated by dashes Word separators and punctuation symbols (comma, dot, hyphen, colon, semicolon, braces, quotes etc) are ignored 20156

Algorithm (6) Create a n * m matrix (n > 5, m > 5) Find: The sum of the negative elements in the last row The sum of positive elements in a column. Only show the sums from the columns to the right of the third column. Show sum for each column separately. The product of negative elements in a row. Do this for rows higher than the fourth row. Show product for each row separately. Display all the results found

Algorithm (7) You’re given an array of integers with a length of N Place the elements so that negative numbers come first and positive numbers follow them Don’t change the order of appearance E.g. Original: 5, -7, -87, -221, 7, 97, 1, -5, 5 Result: -7, -87, -221, -5, 5, 7, 97, 1,

Algorithm (8) Read product weights and codes from a file Find extremums and ratios between weights and extremums Output ratios with product codes E.g.Weights: 6, 7, 2, 10, 4 Prod. codes: 790A1, 001A1, 117CA, 000A2, Product 790A1 ratios are 3.0 and 0.6 Product 001A1 ratios are 3.5 and 0.7 Product 117CA ratios are 1.0 and 0.2 etc 20159

Algorithm (9) User inputs decimal numbers (integers) from the keyboard until ‘0’ is typed User inputs a new base (radix) Sisse loetud arvud teisendatakse soovitud arvusüsteemi ja väljastatakse kõrvuti nende kümnendsüsteemi väärtustega

Algorithm (10) N 4-byte binary numbers are read from a file Numbers will be converted into decimal and hexadecimal Results will be stored in a file alongside their originals in binary