C++ For Science and Engineering Lecture 13
|
|
- Michael Blankenship
- 6 years ago
- Views:
Transcription
1 C++ For Science and Engineering Lecture 13 John Chrispell Tulane University Wednesday September 22, 2010
2 Logical Expressions: Sometimes you want to use logical and and logical or (even logical not) in you statements to test several conditions. C++ allows us to do this using the logical and, logical or and logical not operators. Denoted: && // L o g i c a l AND // L o g i c a l OR! // L o g i c a l NOT Note in most cases other than not equal it is clearer to write: i f ( x <= 5) than i f (! ( x > 5 ) ) even if these statements are equal. John Chrispell, Wednesday September 22, 2010 slide 3/31
3 Logical Expressions: The logical AND and logical OR operators have a lower precedence than the relational operators. This means that an expression such as x > 5 && x < 10 i s read as ( x > 5) && ( x < 10) The logical NOT operator has a higer precedence than any of the relational or aritmatic operators.! ( x > 5) // I s i t f a l s e t h a t x i s g r e a t e r than 5?! x > 5 // I s! x g r e a t e r than 5? Logical AND has higer precedence than logical OR. Thus, age > 30 && age < 45 weight > 300 means ( age > 30 && age < 45) weight > 300 John Chrispell, Wednesday September 22, 2010 slide 5/31
4 Logical Expressions: 1 C++ allows you to type the text values and, or, and not for the symbols used in previous examples. 2 These are reserve key words in C++. 3 This advanced format can be used in C as well provided the iso646.h header file is included. The following listing is an example of using the Logical NOT operator. John Chrispell, Wednesday September 22, 2010 slide 7/31
5 not.cpp #include <iostream > #include <c l i m i t s > bool i s i n t ( double ) ; i n t main ( ) { using namespace std ; double num ; cout << Enter an i n t e g e r v a l u e : ; c i n >> num ; while (! i s i n t (num)){ // c o n t i n u e w h i l e num i s not i n t a b l e cout << Out of range p l e a s e t r y again : ; c i n >> num ; i n t val = i n t (num ) ; // typecast cout << You ve e n t e r e d the i n t e g e r << v a l << \nbye\n ; return 0 ; bool i s i n t ( double x ){ i f ( ( x <= INT MAX) && ( x >= INT MIN ) ) { // use c l i m i t s v a l u e s return true ; e l s e { return false ; John Chrispell, Wednesday September 22, 2010 slide 9/31
6 cctype character functions Each function takes a character: isalnum Check if character is alphanumeric isalpha Check if character is alphabetic iscntrl Check if character is a control character isdigit Check if character is decimal digit isgraph Check if character is any printing character other than a space islower Check if character is lowercase letter isprint Check if character is printable (including space) ispunct Check if character is a punctuation character isspace Check if character is a white-space isupper Check if character is uppercase letter isxdigit Check if character is hexadecimal digit tolower Convert uppercase letter to lowercase toupper Convert lowercase letter to uppercase John Chrispell, Wednesday September 22, 2010 slide 11/31
7 cctypes.cpp #i n c lude <iostream > #i n c lude <cctype > // p r o t o t y p e s f o r c h a r a c t e r f u n c t i o n s i n t main ( ) { using namespace std ; cout << Enter text for analysis, and to t e rm i na te i npu t. \ n ; char ch ; i n t w h i t e s p a c e = 0 ; i n t d i g i t s = 0 ; i n t c h a r s = 0 ; i n t punct = 0 ; i n t o t h e r s = 0 ; c i n. get ( ch ) ; // get f i r s t c h a r a c t e r while ( ){ // t e s t f o r s e n t i n e l i f ( isalpha ( ch ) ) // is it an alphabetic character? c h a r s ++; else i f ( isspace ( ch ) ) // is it a whitespace character? w h i t e s p a c e ++; e l s e i f ( i s d i g i t ( ch ) ) // i s i t a d i g i t? d i g i t s ++; else i f ( ispunct ( ch ) ) // is it punctuation? punct++; e l s e o t h e r s ++; c i n. get ( ch ) ; // get next c h a r a c t e r cout << c h a r s << l e t t e r s, << whitespace << whitespace, << d i g i t s << d i g i t s, << punct << punctuations, << o t h e r s << o t h e r s. \ n ; return 0 ; John Chrispell, Wednesday September 22, 2010 slide 13/31
8 The?: Operator C++ has one operator that takes three operands, and can be used to replace the if else statement. e x p r e s s i o n 1? e x p r e s s i o n 2 : e x p r e s s i o n 3 if expression1 is true then the value of the whole conditional is expression2. Otherwise it takes on the value of expression3. 5 > 3? 10 : 1 2 ; // Has v a l u e 10 3 == 9? 25 : 1 8 ; // Has v a l u e 18 John Chrispell, Wednesday September 22, 2010 slide 15/31
9 condit.cpp #i n c l u d e <i o s t r e a m > i n t main ( ) { using namespace std ; / ========================= / / A max f u n c t i o n / / ========================= / i n t a, b ; cout << Enter two i n t e g e r s : ; c i n >> a >> b ; cout << The l a r g e r o f << a << and << b ; i n t c = a > b? a : b ; // c = a i f a > b, e l s e c = b cout << i s << c << endl ; / ========================= / / Fancy P r i n t Statement / / ========================= / const char x [ 2 ] [ 2 0 ] = { Jason, at your s e r v i c e \n ; const char y = Q u i l l s t o n e ; f o r ( i n t i = 0 ; i < 3 ; i ++){ cout << ( ( i < 2)?! i? x [ i ] : y : x [ 1 ] ) ; return 0 ; John Chrispell, Wednesday September 22, 2010 slide 17/31
10 The switch statement You can extend the if else if else sequence by using the C++ switch statement. switch ( i n t e g e r e x p r e s s i o n ){ case l a b e l 1 : s t a t e m e n t ( s ) case l a b e l 2 : s t a t e m e n t ( s )... d e f a u l t : s tatement ( s ) Consider the following example! John Chrispell, Wednesday September 22, 2010 slide 19/31
11 switch.cpp #include <iostream > using namespace std ; void showmenu ( ) ; // f u n c t i o n p r o t o t y p e s void r e p o r t ( ) ; void comfort ( ) ; i n t main ( ) { showmenu ( ) ; i n t choice ; cin >> choice ; while ( c h o i c e!= 6) { switch ( c h o i c e ) { case 1 : cout << None o f the Homework i s graded! \ n ; break ; case 2 : r e p o r t ( ) ; break ; case 3 : cout << A l l the Homework i s graded. \ n ; break ; case 4 : case 5 : comfort ( ) ; break ; d e f a u l t : cout << That s not a c h o i c e. \ n ; showmenu ( ) ; cin >> choice ; cout << Bye! \ n ; return 0 ; void showmenu ( ) { cout << P l e a s e e n t e r 1, 2, 3, 4, or 5 : \ n 1) alarm 2) r e p o r t \n 3) a l i b i 4) comfort \n 5) comfort 2 6) q u i t \n ; void r e p o r t ( ) { cout << It s been an excellent week for C++.\n All students did homework. No one i s f a i l i n g. \ n ; void comfort ( ) { cout << Your s t u d e n t s t h i n k you are the f i n e s t C++ t e a c h e r e v e r! \ n They w i l l a l l go on to be g r e a t programmers. \ n ; John Chrispell, Wednesday September 22, 2010 slide 21/31
12 enum.cpp Enumerators can be used as labels for switch case statements. #i n c l u d e <iostream > i n t main ( ) { using namespace std ; / c r e a t e named c o n s t a n t s f o r 0 6 / enum { red, orange, yellow, green, blue, v i o l e t, i n d i g o ; cout << Enter color code (0 6): ; i n t code ; c i n >> code ; while ( code >= red && code <= i n d i g o ){ switch ( code ){ case red : cout << Her l i p s were red. \ n ; break ; case orange : cout << Her h a i r was orange. \ n ; break ; case y e l l o w : cout << Her shoes were y e l l o w. \ n ; break ; case green : cout << Her n a i l s were green. \ n ; break ; case blue : cout << Her s w e a t s u i t was blue. \ n ; break ; case v i o l e t : cout << Her e y e s were v i o l e t. \ n ; break ; case i n d i g o : cout << Her mood was i n d i g o. \ n ; break ; cout << Enter color code (0 6): ; c i n >> code ; cout << Bye\n ; return 0 ; John Chrispell, Wednesday September 22, 2010 slide 23/31
13 Break and continue statements The break and continue statements allow a program to skip over parts of the code. The break and continue statements may be used in loops allowing the program to jump over statements: while ( c i n. get ( ch ) ) { // ( ) s t a t e m ent 1 i f ( ch == \n ) continue ; // Jumps to ( ) s t a t e m ent 2 s t a t e m ent 3 / c o n t i n u e s k i p s the r e s t o f the body and s t a r t s a new c y c l e / / / while ( c i n. get ( ch ) ) { s t a t e m ent 1 i f ( ch == \n ) break ; // Jumps to (+++) s t a t e m ent 2 s t a t e m ent 3 // (+++) / break s k i p s the r e s t of the loop and goes on to the next statement / John Chrispell, Wednesday September 22, 2010 slide 25/31
14 jump.cpp #i n c l u d e <iostream > const i n t A r S i z e = 8 0 ; i n t main ( ) { using namespace std ; char l i n e [ A r S i z e ] ; i n t s p a c e s = 0 ; cout << Enter a l i n e o f t e x t : \ n ; c i n. get ( l i n e, A r S i z e ) ; cout << Complete l i n e : \ n << l i n e << e n d l ; cout << L i n e through f i r s t p e r i o d : \ n ; f o r ( i n t i = 0 ; l i n e [ i ]!= \0 ; i ++){ cout << l i n e [ i ] ; // d i s p l a y c h a r a c t e r i f ( l i n e [ i ] ==. ) // q u i t i f i t s a p e r i o d break ; i f ( l i n e [ i ]!= ) // s k i p r e s t o f l o o p continue ; s p a c e s ++; cout << \n << spaces << spaces \n ; cout << Done. \ n ; return 0 ; We are going to forget that C and C++ have goto statements. John Chrispell, Wednesday September 22, 2010 slide 27/31
15 cinfish.cpp #i n c l u d e <i o s t ream > const i n t Max = 5 ; i n t main ( ) { using namespace std ; double f i s h [Max ] ; cout << Please enter the weights of your f i s h. \ n ; cout << You may e n t e r up to << Max << f i s h <q to terminate >.\n ; cout << f i s h #1: ; i n t i = 0 ; while ( i < Max && c i n >> f i s h [ i ] ) { i f (++ i < Max){ cout << f i s h # << i +1 << : ; / =================== / / c a l c u l a t e a v e r a g e / / =================== / double t o t a l = 0. 0 ; f o r ( i n t j = 0 ; j < i ; j ++){ t o t a l += f i s h [ j ] ; / =================== / / r e p o r t r e s u l t s / / =================== / i f ( i == 0){ cout << No f i s h \n ; e l s e { cout << t o t a l / i << = a v e r a g e weight o f << i << f i s h \n ; cout << Done. \ n ; return 0 ; The above listing is an example of using non numeric data to teminat a loop. As cin gives an error if inproper values are read. John Chrispell, Wednesday September 22, 2010 slide 29/31
16 user input If the user of a program enters the wrong data. We need to take three steps: Reset cin to accept ne input. Get rid of the bad data. Prompt the user to try again. We reset cin by using the member function clear. Consider the following: John Chrispell, Wednesday September 22, 2010 slide 31/31
17 cingolf.cpp / ========================================== / / example where non numeric input i s skipped / / ========================================== / #include <iostream > const i n t Max = 5 ; i n t main ( ) { using namespace std ; // get data i n t g o l f [ Max ] ; cout << Please enter your g o l f s c o r e s. \ n ; cout << You must e n t e r << Max << rounds. \ n ; i n t i ; f o r ( i = 0 ; i < Max ; i ++){ cout << round # << i +1 << : ; while (! ( c i n >> g o l f [ i ] ) ) { c i n. c l e a r ( ) ; // r e s e t i n p u t while ( c i n. get ( )!= \n ) continue ; // get r i d o f bad i n p u t cout << Please enter a number : ; // c a l c u l a t e a v e r a g e double t o t a l = 0. 0 ; f o r ( i = 0 ; i < Max ; i ++) t o t a l += g o l f [ i ] ; // r e p o r t r e s u l t s cout << total / Max << = average score << Max << rounds \n ; return 0 ; John Chrispell, Wednesday September 22, 2010 slide 33/31
C++ For Science and Engineering Lecture 14
C++ For Science and Engineering Lecture 14 John Chrispell Tulane University Monday September 27, 2010 File Input and Output Recall writing text to standard out You must include the iostream header file.
More informationMore Example Using Loops
Loops and Repetitive Computations For More Example Using Loops Example 35 (contd) printing of first row print the first day i= i+1 no i < 7? yes printf("%6d", i) exit no i < =n? i = i+7 printf("\n") printing
More informationC++ For Science and Engineering Lecture 10
C++ For Science and Engineering Lecture 10 John Chrispell Tulane University Wednesday 15, 2010 Introducing for loops Often we want programs to do the same action more than once. #i n c l u d e
More informationC++ For Science and Engineering Lecture 17
C++ For Science and Engineering Lecture 17 John Chrispell Tulane University Monday October 4, 2010 Functions and C-Style Strings Three methods for representing the C-style string: An array of char A quoted
More informationC++ For Science and Engineering Lecture 8
C++ For Science and Engineering Lecture 8 John Chrispell Tulane University Friday 10, 2010 Arrays Structures are ways of storing more than one type of information together. A structure is a vesatile data
More informationCS 7B - Fall Final Exam (take-home portion). Due Wednesday, 12/13 at 2 pm
CS 7B - Fall 2017 - Final Exam (take-home portion). Due Wednesday, 12/13 at 2 pm Write your responses to following questions on separate paper. Use complete sentences where appropriate and write out code
More informationCS 7B - Spring Assignment: Adapting the calculator for bitwise expressions. due 2/21/18
CS 7B - Spring 2018 - Assignment: Adapting the calculator for bitwise expressions. due 2/21/18 Background Theory A bitwise number is a number in base 2. In base 2, place values are either a 1 or 0, depending
More information2. Write a recursive function to add the first n terms of the alternating harmonic series:
CS 7B - Spring 2014 - Midterm 2. 5/8/14 Write responses on separate paper. 1. Write a recursive method that uses only addition, subtraction, and comparison to multiply two numbers. The basic engine for
More informationCS Exam 1 Study Guide and Practice Exam
CS 150 - Exam 1 Study Guide and Practice Exam September 11, 2017 Summary 1 Disclaimer 2 Variables 2.1 Primitive Types.............................................. 2.2 Suggestions, Warnings, and Resources.................................
More informationDigital Logic (2) Boolean Algebra
Digital Logic (2) Boolean Algebra Boolean algebra is the mathematics of digital systems. It was developed in 1850 s by George Boole. We will use Boolean algebra to minimize logic expressions. Karnaugh
More informationNumerical solution of the time-independent 1-D Schrödinger equation. Matthias E. Möbius. September 24, 2010
Numerical solution of the time-independent 1-D Schrödinger equation Matthias E. Möbius September 24, 2010 1 Aim of the computational lab Numerical solution of the one-dimensional stationary Schrödinger
More informationCS 7B - Fall Assignment 4: Exploring Wumpus (Linked Rooms). Due 12/13/18
CS 7B - Fall 2018 - Assignment 4: Exploring Wumpus (Linked Rooms). Due 12/13/18 In this project we ll build, investigate and augment the the game Hunt the Wumpus, as described in exercise 12 or PPP2, Chapter
More informationUNIVERSITY POLYTECHNIC B.I.T., MESRA, RANCHI. COURSE STRUCTURE (W.E.F Batch Students) (Total Unit 7.5)
COURSE STRUCTURE (W.E.F. 2011 Batch Students) (Total Unit 7.5) Course Code Theory Unit Course Code Sessional Unit DMA 3001 Mathematics III 1.0 DEC 3002 Basic Electronics Lab. 0.5 DEC 3001 Basic Electronics
More information12/31/2010. Digital Operations and Computations Course Notes. 01-Number Systems Text: Unit 1. Overview. What is a Digital System?
Digital Operations and Computations Course Notes 0-Number Systems Text: Unit Winter 20 Professor H. Louie Department of Electrical & Computer Engineering Seattle University ECEGR/ISSC 20 Digital Operations
More informationPaterson Public Schools
A. Concepts About Print Understand how print is organized and read. (See LAL Curriculum Framework Grade KR Page 1 of 12) Understand that all print materials in English follow similar patterns. (See LAL
More informationCSE 311: Foundations of Computing. Lecture 26: Cardinality
CSE 311: Foundations of Computing Lecture 26: Cardinality Cardinality and Computability Computers as we know them grew out of a desire to avoid bugs in mathematical reasoning A brief history of reasoning
More informationFIT100 Spring 01. Project 2. Astrological Toys
FIT100 Spring 01 Project 2 Astrological Toys In this project you will write a series of Windows applications that look up and display astrological signs and dates. The applications that will make up the
More informationCSE 20. Lecture 4: Introduction to Boolean algebra. CSE 20: Lecture4
CSE 20 Lecture 4: Introduction to Boolean algebra Reminder First quiz will be on Friday (17th January) in class. It is a paper quiz. Syllabus is all that has been done till Wednesday. If you want you may
More informationOn my honor, as an Aggie, I have neither given nor received unauthorized aid on this academic work
Lab 5 : Linking Name: Sign the following statement: On my honor, as an Aggie, I have neither given nor received unauthorized aid on this academic work 1 Objective The main objective of this lab is to experiment
More informationWeek No. 06: Numbering Systems
Week No. 06: Numbering Systems Numbering System: A numbering system defined as A set of values used to represent quantity. OR A number system is a term used for a set of different symbols or digits, which
More informationω = k/m x = A cos (ωt + ϕ 0 ) L = I ω a x = ω 2 x P = F v P = de sys J = F dt = p w = m g F G = Gm 1m 2 D = 1 2 CρAv2 a r = v2
PHYS 2211 A & B Final Exam Formulæ & Constants Fall 2016 Unless otherwise directed, all problems take place on Earth, and drag is to be neglected. A v = d r ω = dθ a = d v α = d ω v sf = v si + a s t ω
More informationSlides for a Course Based on the Text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen
University of Florida Dept. of Computer & Information Science & Engineering COT 3100 Applications of Discrete Structures Dr. Michael P. Frank Slides for a Course Based on the Text Discrete Mathematics
More informationComp 11 Lectures. Mike Shah. July 26, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures July 26, / 40
Comp 11 Lectures Mike Shah Tufts University July 26, 2017 Mike Shah (Tufts University) Comp 11 Lectures July 26, 2017 1 / 40 Please do not distribute or host these slides without prior permission. Mike
More informationEEE130 Digital Electronics I Lecture #4
EEE130 Digital Electronics I Lecture #4 - Boolean Algebra and Logic Simplification - By Dr. Shahrel A. Suandi Topics to be discussed 4-1 Boolean Operations and Expressions 4-2 Laws and Rules of Boolean
More informationDiscrete Structures Homework 1
Discrete Structures Homework 1 Due: June 15. Section 1.1 16 Determine whether these biconditionals are true or false. a) 2 + 2 = 4 if and only if 1 + 1 = 2 b) 1 + 1 = 2 if and only if 2 + 3 = 4 c) 1 +
More informationThe Monte Carlo Algorithm
The Monte Carlo Algorithm This algorithm was invented by N. Metropolis, A.W. Rosenbluth, M.N. Rosenbluth, A.H. Teller, and E. Teller, J. Chem. Phys., 21, 1087 (1953). It was listed as one of the The Top
More informationimport java. u t i l. ;... Scanner sc = new Scanner ( System. in ) ;
CPSC 490 Input Input will always arrive on stdin. You may assume input is well-formed with respect to the problem specification; inappropriate input (e.g. text where a number was specified, number out
More informationString Matching II. Algorithm : Design & Analysis [19]
String Matching II Algorithm : Design & Analysis [19] In the last class Simple String Matching KMP Flowchart Construction Jump at Fail KMP Scan String Matching II Boyer-Moore s heuristics Skipping unnecessary
More informationCHEM 121 Introduction to Fundamental Chemistry. Summer Quarter 2008 SCCC. Lecture 2
CHEM 121 Introduction to Fundamental Chemistry Summer Quarter 2008 SCCC Lecture 2 Could Stephanie, Liqingqing, Huong, Sophia and Yumiko see me after class for a few minutes. Thanks. Matter, Measurements
More informationNUMERICAL ANALYSIS WEEKLY OVERVIEW
NUMERICAL ANALYSIS WEEKLY OVERVIEW M. AUTH 1. Monday 28 August Students are encouraged to download Anaconda Python. Anaconda is a version of Python that comes with some numerical packages (numpy and matplotlib)
More informationData Structure and Algorithm Homework #1 Due: 2:20pm, Tuesday, March 12, 2013 TA === Homework submission instructions ===
Data Structure and Algorithm Homework #1 Due: 2:20pm, Tuesday, March 12, 2013 TA email: dsa1@csie.ntu.edu.tw === Homework submission instructions === For Problem 1, submit your source code, a Makefile
More informationIntroduction to Python for Biologists
Introduction to Python for Biologists Katerina Taškova 1 Jean-Fred Fontaine 1,2 1 Faculty of Biology, Johannes Gutenberg-Universität Mainz, Mainz, Germany 2 Genomics and Computational Biology, Kernel Press,
More informationIntroduction to Computer Programming, Spring Term 2018 Practice Assignment 3 Discussion:
German University in Cairo Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Mohammed Abdel Megeed Introduction to Computer Programming, Spring Term 2018 Practice Assignment 3 Discussion:
More informationComp 11 Lectures. Mike Shah. June 20, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures June 20, / 38
Comp 11 Lectures Mike Shah Tufts University June 20, 2017 Mike Shah (Tufts University) Comp 11 Lectures June 20, 2017 1 / 38 Please do not distribute or host these slides without prior permission. Mike
More informationDiscrete Structures CRN Test 3 Version 1 CMSC 2123 Spring 2011
Discrete Structures CRN 1858 Test 3 Version 1 CMSC 13 Spring 011 1. Print your name on your scantron in the space labeled NAME.. Print CMSC 13 in the space labeled SUBJECT. 3. Print the date, 5--011, in
More informationComputer Science Introductory Course MSc - Introduction to Java
Computer Science Introductory Course MSc - Introduction to Java Lecture 1: Diving into java Pablo Oliveira ENST Outline 1 Introduction 2 Primitive types 3 Operators 4 5 Control Flow
More informationIntroductory Probability
Introductory Probability Discrete Probability Distributions Dr. Nguyen nicholas.nguyen@uky.edu Department of Mathematics UK January 9, 2019 Agenda Syllabi and Course Websites Class Information Random Variables
More informationFormal Methods in Software Engineering
Formal Methods in Software Engineering Modeling Prof. Dr. Joel Greenyer October 21, 2014 Organizational Issues Tutorial dates: I will offer two tutorial dates Tuesdays 15:00-16:00 in A310 (before the lecture,
More informationMathematics Practice Test 2
Mathematics Practice Test 2 Complete 50 question practice test The questions in the Mathematics section require you to solve mathematical problems. Most of the questions are presented as word problems.
More informationCS 163/164 - Exam 1 Study Guide and Practice Exam
CS 163/164 - Exam 1 Study Guide and Practice Exam September 11, 2017 Summary 1 Disclaimer 2 Variables 2.1 Primitive Types.............................................. 2.2 Strings...................................................
More informationNumbering Systems. Contents: Binary & Decimal. Converting From: B D, D B. Arithmetic operation on Binary.
Numbering Systems Contents: Binary & Decimal. Converting From: B D, D B. Arithmetic operation on Binary. Addition & Subtraction using Octal & Hexadecimal 2 s Complement, Subtraction Using 2 s Complement.
More informationOur Final Exam will be on Monday, April 27 at 8:00am!
Physics 2211 BCD Test form Name Spring 2015 Test 4 Recitation Section (see back of test): 1) Print your name, test form number (above), and nine-digit student number in the section of the answer card labeled
More informationSpelling Contracts. Contract options and activity worksheets are included below. Photos illustrate some activities and organization of materials.
Spelling Contracts For the past three and a half years I have used spelling contracts in my classroom. This idea was first suggested to me by Nancy Greenwald, a retired teacher and friend. She provided
More informationE23: Hotel Management System Wen Yunlu Hu Xing Chen Ke Tang Haoyuan Module: EEE 101
E23: Hotel Management System Author: 1302509 Zhao Ruimin 1301478 Wen Yunlu 1302575 Hu Xing 1301911 Chen Ke 1302599 Tang Haoyuan Module: EEE 101 Lecturer: Date: Dr.Lin December/22/2014 Contents Contents
More informationCongratulations you're done with CS103 problem sets! Please evaluate this course on Axess!
The Big Picture Announcements Problem Set 9 due right now. We'll release solutions right after lecture. Congratulations you're done with CS103 problem sets! Practice final exam is Monday, December 8 from
More informationHomework #5 Solution Due Thursday, December 01, 2011
12.010 Homework #5 Solution Due Thursday, December 01, 2011 Question (1): (25- points) (a) Write a Matlab M- file which generates a table of error function (erf) and its derivatives for real arguments
More information10. Finite Automata and Turing Machines
. Finite Automata and Turing Machines Frank Stephan March 2, 24 Introduction Alan Turing s th Birthday Alan Turing was a completely original thinker who shaped the modern world, but many people have never
More informationName: Section: 4A 4B 4C 4D 4E
Name: Section: 4A 4B 4C 4D 4E Homework Hello Scholars. We will continue reviewing 4 th grade math standards in preparation for the Math. Scholars will review 4 th grade math standards throughout the week
More informationCluster Algorithms to Reduce Critical Slowing Down
Cluster Algorithms to Reduce Critical Slowing Down Monte Carlo simulations close to a phase transition are affected by critical slowing down. In the 2-D Ising system, the correlation length ξ becomes very
More informationPropositional Logic: Semantics and an Example
Propositional Logic: Semantics and an Example CPSC 322 Logic 2 Textbook 5.2 Propositional Logic: Semantics and an Example CPSC 322 Logic 2, Slide 1 Lecture Overview 1 Recap: Syntax 2 Propositional Definite
More informationUsing Microsoft Excel
Using Microsoft Excel Objective: Students will gain familiarity with using Excel to record data, display data properly, use built-in formulae to do calculations, and plot and fit data with linear functions.
More informationThe Euler Method for the Initial Value Problem
The Euler Method for the Initial Value Problem http://people.sc.fsu.edu/ jburkardt/isc/week10 lecture 18.pdf... ISC3313: Introduction to Scientific Computing with C++ Summer Semester 2011... John Burkardt
More informationOur Final Exam will be held on Monday, December 7 at 8:00am!
Physics 2211 A/B Test form Name Fall 2015 Exam 4 Recitation Section (see back of test): 1) Print your name, test form number (above), and nine-digit student number in the section of the answer card labeled
More informationCS 7B - Spring Assignment: Ramsey Theory with Matrices and SFML. due 5/23/18
CS 7B - Spring 2018 - Assignment: Ramsey Theory with Matrices and SFML. due 5/23/18 Background Theory Ramsey theory, named after the British mathematician and philosopher Frank P. Ramsey, is a branch of
More informationLecture 3: Finite Automata
Administrivia Lecture 3: Finite Automata Everyone should now be registered electronically using the link on our webpage. If you haven t, do so today! I d like to have teams formed by next Wednesday at
More informationProject Management Prof. Raghunandan Sengupta Department of Industrial and Management Engineering Indian Institute of Technology Kanpur
Project Management Prof. Raghunandan Sengupta Department of Industrial and Management Engineering Indian Institute of Technology Kanpur Module No # 07 Lecture No # 35 Introduction to Graphical Evaluation
More informationDISCRETE RANDOM VARIABLES EXCEL LAB #3
DISCRETE RANDOM VARIABLES EXCEL LAB #3 ECON/BUSN 180: Quantitative Methods for Economics and Business Department of Economics and Business Lake Forest College Lake Forest, IL 60045 Copyright, 2011 Overview
More informationAppendix A. Review of Basic Mathematical Operations. 22Introduction
Appendix A Review of Basic Mathematical Operations I never did very well in math I could never seem to persuade the teacher that I hadn t meant my answers literally. Introduction Calvin Trillin Many of
More informationCPSC 121 Sample Final Examination December 2013
CPSC 121 Sample Final Examination December 201 [6] 1. Short answers [] a. What is wrong with the following circuit? You can not connect the outputs of two or more gates together directly; what will happen
More informationNAME: DATE: MATHS: Higher Level Algebra. Maths. Higher Level Algebra
Maths Higher Level Algebra It is not necessary to carry out all the activities contained in this unit. Please see Teachers Notes for explanations, additional activities, and tips and suggestions. Theme
More informationMaths Higher Level Algebra
Maths Higher Level Algebra It is not necessary to carry out all the activities contained in this unit. Please see Teachers Notes for explanations, additional activities, and tips and suggestions. Theme
More informationComputational Physics (6810): Session 2
Computational Physics (6810): Session 2 Dick Furnstahl Nuclear Theory Group OSU Physics Department January 13, 2017 Session 1 follow-ups Types of error Reminder of power laws Session 1 follow-ups Session
More informationHomework 1. Johan Jensen ABSTRACT. 1. Theoretical questions and computations related to digital representation of numbers.
Homework 1 Johan Jensen This homework has three parts. ABSTRACT 1. Theoretical questions and computations related to digital representation of numbers. 2. Analyzing digital elevation data from the Mount
More informationComparing whole genomes
BioNumerics Tutorial: Comparing whole genomes 1 Aim The Chromosome Comparison window in BioNumerics has been designed for large-scale comparison of sequences of unlimited length. In this tutorial you will
More informationCongratulations you're done with CS103 problem sets! Please evaluate this course on Axess!
The Big Picture Announcements Problem Set 9 due right now. We'll release solutions right after lecture. Congratulations you're done with CS103 problem sets! Please evaluate this course on Axess! Your feedback
More informationStudents should be able to (a) produce a truth table from a given logic diagram
Truth tables Teacher s Notes Lesson Plan Length 60 mins Specification Link 2.1.2/f inary logic Learning objective Students should be able to (a) produce a truth table from a given logic diagram Time (min)
More informationNAME: DATE: MATHS: Working with Sets. Maths. Working with Sets
Maths Working with Sets It is not necessary to carry out all the activities contained in this unit. Please see Teachers Notes for explanations, additional activities, and tips and suggestions. Theme All
More informationIn this approach, the ground state of the system is found by modeling a diffusion process.
The Diffusion Monte Carlo (DMC) Method In this approach, the ground state of the system is found by modeling a diffusion process. Diffusion and random walks Consider a random walk on a lattice with spacing
More informationDARN: A Matrix Manipulation Language
DARN: A Matrix Manipulation Language Daisy Chaussee (dac2183) Anthony Kim (ak3703) Rafael Takasu (rgt2108) Ignacio (Nacho) Torras (it2216) December 20, 2016 1 Contents 1 Introduction to the Language 4
More informationTuring Machines Part III
Turing Machines Part III Announcements Problem Set 6 due now. Problem Set 7 out, due Monday, March 4. Play around with Turing machines, their powers, and their limits. Some problems require Wednesday's
More informationQuiz 2 out of 50 points
Quiz 2 out of 50 points Print your name on the line below. Do not turn this page over until told by the staff to do so. This quiz is closed-book. However, you may utilize during the quiz one two-sided
More informationComp 11 Lectures. Mike Shah. July 12, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures July 12, / 33
Comp 11 Lectures Mike Shah Tufts University July 12, 2017 Mike Shah (Tufts University) Comp 11 Lectures July 12, 2017 1 / 33 Please do not distribute or host these slides without prior permission. Mike
More informationBishop Kelley High School Summer Math Program Course: Algebra II B
016 017 Summer Math Program Course: NAME: DIRECTIONS: Show all work in the packet. You may not use a calculator. No matter when you have math, this packet is due on the first day of class This material
More informationEXPERIMENT: REACTION TIME
EXPERIMENT: REACTION TIME OBJECTIVES to make a series of measurements of your reaction time to make a histogram, or distribution curve, of your measured reaction times to calculate the "average" or "mean"
More informationCHM111 Lab Math Review Grading Rubric
Name CHM111 Lab Math Review Grading Rubric Part 1. Basic Algebra and Percentages Criteria Points possible Points earned Question 1 (0.25 points each question) 2 Question 2 (0.25 points each question) 1
More informationHomework. Turing Machines. Announcements. Plan for today. Now our picture looks like. Languages
Homework s TM Variants and the Universal TM Homework #6 returned Homework #7 due today Homework #8 (the LAST homework!) Page 262 -- Exercise 10 (build with JFLAP) Page 270 -- Exercise 2 Page 282 -- Exercise
More informationE40M. Binary Numbers. M. Horowitz, J. Plummer, R. Howe 1
E40M Binary Numbers M. Horowitz, J. Plummer, R. Howe 1 Reading Chapter 5 in the reader A&L 5.6 M. Horowitz, J. Plummer, R. Howe 2 Useless Box Lab Project #2 Adding a computer to the Useless Box alows us
More informationEXPERIMENT 2 Reaction Time Objectives Theory
EXPERIMENT Reaction Time Objectives to make a series of measurements of your reaction time to make a histogram, or distribution curve, of your measured reaction times to calculate the "average" or mean
More informationNorthwest High School s Algebra 1
Northwest High School s Algebra 1 Summer Review Packet 2011 DUE WEDNESDAY, SEPTEMBER 2, 2011 Student Name This packet has been designed to help you review various mathematical topics that will be necessary
More informationTuring Machines Part Three
Turing Machines Part Three What problems can we solve with a computer? What kind of computer? Very Important Terminology Let M be a Turing machine. M accepts a string w if it enters an accept state when
More informationFrom Greek philosophers to circuits: An introduction to boolean logic. COS 116, Spring 2011 Sanjeev Arora
From Greek philosophers to circuits: An introduction to boolean logic. COS 116, Spring 2011 Sanjeev Arora Midterm One week from today in class Mar 10 Covers lectures, labs, homework, readings to date You
More informationEDA045F: Program Analysis LECTURE 10: TYPES 1. Christoph Reichenbach
EDA045F: Program Analysis LECTURE 10: TYPES 1 Christoph Reichenbach In the last lecture... Performance Counters Challenges in Dynamic Performance Analysis Taint Analysis Binary Instrumentation 2 / 44 Types
More informationBinary addition example worked out
Binary addition example worked out Some terms are given here Exercise: what are these numbers equivalent to in decimal? The initial carry in is implicitly 0 1 1 1 0 (Carries) 1 0 1 1 (Augend) + 1 1 1 0
More informationAutomata and Computability. Solutions to Exercises
Automata and Computability Solutions to Exercises Spring 27 Alexis Maciel Department of Computer Science Clarkson University Copyright c 27 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata
More informationSoftware Testing Lecture 2
Software Testing Lecture 2 Justin Pearson September 25, 2014 1 / 1 Test Driven Development Test driven development (TDD) is a way of programming where all your development is driven by tests. Write tests
More informationCS 177 Fall 2014 Midterm 1 exam - October 9th
CS 177 Fall 2014 Midterm 1 exam - October 9th There are 25 True/False and multiple choice questions. Each one is worth 4 points. Answer the questions on the bubble sheet given to you. Remember to fill
More informationCSE 20 DISCRETE MATH. Fall
CSE 20 DISCRETE MATH Fall 2017 http://cseweb.ucsd.edu/classes/fa17/cse20-ab/ Today's learning goals Describe and use algorithms for integer operations based on their expansions Relate algorithms for integer
More informationMath 20 Spring Discrete Probability. Midterm Exam
Math 20 Spring 203 Discrete Probability Midterm Exam Thursday April 25, 5:00 7:00 PM Your name (please print): Instructions: This is a closed book, closed notes exam. Use of calculators is not permitted.
More informationCompanion. Jeffrey E. Jones
MATLAB7 Companion 1O11OO1O1O1OOOO1O1OO1111O1O1OO 1O1O1OO1OO1O11OOO1O111O1O1O1O1 O11O1O1O11O1O1O1O1OO1O11O1O1O1 O1O1O1111O11O1O1OO1O1O1O1OOOOO O1111O1O1O1O1O1O1OO1OO1OO1OOO1 O1O11111O1O1O1O1O Jeffrey E.
More informationForm #425 Page 1 of 6
Version Quiz #4 Form #425 Name: A Physics 2212 G Spring 2018 Recitation Section: Print your name, quiz form number (3 digits at the top of this form), and student number (9 digit Georgia Tech ID number)
More informationAn Introduction to Matrix Algebra
An Introduction to Matrix Algebra EPSY 905: Fundamentals of Multivariate Modeling Online Lecture #8 EPSY 905: Matrix Algebra In This Lecture An introduction to matrix algebra Ø Scalars, vectors, and matrices
More informationAutomata and Computability. Solutions to Exercises
Automata and Computability Solutions to Exercises Fall 28 Alexis Maciel Department of Computer Science Clarkson University Copyright c 28 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata
More informationChapter 5. Piece of Wisdom #2: A statistician drowned crossing a stream with an average depth of 6 inches. (Anonymous)
Chapter 5 Deviating from the Average In This Chapter What variation is all about Variance and standard deviation Excel worksheet functions that calculate variation Workarounds for missing worksheet functions
More informationAlgorithms and Data S tructures Structures Complexity Complexit of Algorithms Ulf Leser
Algorithms and Data Structures Complexity of Algorithms Ulf Leser Content of this Lecture Efficiency of Algorithms Machine Model Complexity Examples Multiplication of two binary numbers (unit cost?) Exact
More informationStat Lecture 20. Last class we introduced the covariance and correlation between two jointly distributed random variables.
Stat 260 - Lecture 20 Recap of Last Class Last class we introduced the covariance and correlation between two jointly distributed random variables. Today: We will introduce the idea of a statistic and
More informationINTRODUCTION. This is not a full c-programming course. It is not even a full 'Java to c' programming course.
C PROGRAMMING 1 INTRODUCTION This is not a full c-programming course. It is not even a full 'Java to c' programming course. 2 LITTERATURE 3. 1 FOR C-PROGRAMMING The C Programming Language (Kernighan and
More informationNumbers and Arithmetic
Numbers and Arithmetic See: P&H Chapter 2.4 2.6, 3.2, C.5 C.6 Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University Big Picture: Building a Processor memory inst register file alu
More informationCS 221 Lecture 9. Tuesday, 1 November 2011
CS 221 Lecture 9 Tuesday, 1 November 2011 Some slides in this lecture are from the publisher s slides for Engineering Computation: An Introduction Using MATLAB and Excel 2009 McGraw-Hill Today s Agenda
More informationLexical Analysis: DFA Minimization & Wrap Up
Lexical Analysis: DFA Minimization & Wrap Up Automating Scanner Construction PREVIOUSLY RE NFA (Thompson s construction) Build an NFA for each term Combine them with -moves NFA DFA (subset construction)
More informationIntroduction to Computer Programming, Spring Term 2018 Practice Assignment 5 Discussion: power(m,n) = m n
German University in Cairo Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Mohammed Abdel Megeed Introduction to Computer Programming, Spring Term 2018 Practice Assignment 5 Discussion:
More information