week 0 - cs50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 computer science 50...

86
0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan [email protected] Week 0

Upload: others

Post on 27-Jun-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

0

Computer Science 50Introduction to Computer Science I

Harvard College

David J. [email protected]

Week 0

Page 2: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

1

Roll Call

1) Stand up.2) Think to yourself “I am #1”.3) Pair up with someone; add your numbers

together; take that sum as your new number.4) One of you should sit down.5) GOTO step 3 if still standing.

Page 3: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

2

Divide and Conquer

Page 4: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

3

Lolcats

Page 5: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

4

Who

Page 6: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

5

“Those Less Comfortable”

Image from stevens.senate.gov.

Page 7: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

6

Prior Programming Experience

Page 8: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

7

Gender

Page 9: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

8

Should I?

Today (9/15), 3:30 – 5, Emerson 105Wednesday (9/17), 3:30 – 5, Emerson 105Thursday (9/18), 3:30 – 5, Emerson 105

Page 10: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

9

0

Page 11: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

10

1

Page 12: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

11

Counting in Binary128s 64s 32s 16s 8s 4s 2s 1s

Page 13: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

12

Counting in Binary128s 64s 32s 16s 8s 4s 2s 1s

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 11

0 0 0 0 0 0 11 0

0 0 0 0 0 0 11 11

0 0 0 0 0 11 0 0

Page 14: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

13

Cambridge in Binary

_ _ _ _ _ _ _ _

_ _ _ _ _ _ _ _

_ _ _ _ _ _ _ _

_ _ _ _ _ _ _ _

_ _ _ _ _ _ _ _

128s 64s 32s 16s 8s 4s 2s 1s

Page 15: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

14

Cambridge in Binary

0 0 0 0 0 0 0 0

0 0 0 0 0 0 11 0

0 0 0 0 0 0 0 11

0 0 0 0 0 0 11 11

0 0 0 0 11 0 0 0

128s 64s 32s 16s 8s 4s 2s 1s

Page 16: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

15

FoxTrot in Binary

Page 17: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

16

ASCII

Page 18: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

17

This is CS 50.Introduction to the intellectual enterprises of computer sciences.

Algorithms: design, implementation, analysis. Software development: abstraction, encapsulations, data structures, debugging, testing.

Architecture of computers: low-level data representation, instructions processing. Computer Systems: programming languages, compilers, operating systems, databases. Computers in the real world: networks,

websites, security, forensics, cryptography. This course teachesstudents how to think more carefully and how to solve problems more

effectively. Problem sets involve extensive programming in C as well as PHP and JavaScript.

No previous programming experience required.

This course, when taken for a letter grade, meets the Core area requirement for Quantitative Reasoning.

Page 19: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

18

Expectations*

Attend all lectures and sectionsComplete nine problem setsTake two quizzesProduce a final project

* No final exam.

Page 20: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

19

Grades*

Problem Sets (best 8 out of 9) 60%Quizzes 30%Final Project 10%

* You may take the course pass/fail.

Page 21: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

20

Website

http://cs50.net/

Page 22: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

21

RecommendedFor Those Less Comfortable

Page 23: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

22

Recommended For Those More Comfortable

Page 24: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

23

Recommended For Everyone

Page 25: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

24

Recommended For Aspiring Hackers

Page 26: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

25

Lectures*

* “Lunch with David” on Fridays ([email protected])

Page 27: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

26

Sections

For “those less comfortable”For “those more comfortable”For those somewhere in between

Page 28: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

27

Staff

Teaching FellowsCourse AssistantsVirtual Teaching FellowsSysadminsScribesProducers, Videographers, AVme

Page 29: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

28

Head TF

Page 30: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

29

Office Hours

Page 31: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

30

Virtual Office Hours

Page 32: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

31

Workload

Page 33: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

32

LecturesWeek 0

Introduction. Bits. Binary. ASCII. Programming. Algorithms. Scratch. Statements. Boolean expressions.

Conditions. Loops. Variables. Threads. Events.

Page 34: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

33

LecturesWeek 1

C. Source code. Compilers. Object code. SSH. SFTP. GCC. Functions. Comments. Standard output. Arithmetic

operators. Precedence. Associativity. Local variables. Types. Casting. Standard input. Libraries. Boolean

expressions, continued. Conditions, continued. Loops, continued.

printf("hai, world\n");

Page 35: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

34

LecturesWeek 2

Functions, continued. Global variables. Parameters. Return Values. Stack. Frames. Scope. Arrays. Strings.

Command-line arguments. Cryptography.

Page 36: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

35

LecturesWeek 3

Linear search. Binary search. Asymptotic notation. Recursion. Pseudorandomness. Bubble sort. Selection

sort. Insertion sort. Merge sort.

Page 37: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

36

LecturesWeek 4

Structures. Dynamic memory allocation. Pointers.

Page 38: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

37

LecturesWeek 5

Pointers, continued. Heap. Debugging. File I/O. Forensics.

Page 39: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

38

Page 40: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

39

LecturesWeek 6

Linked lists.

Figure from http://cs.calvin.edu/books/c++/ds/1e/.

L

first

mySize 5

last9 17 22 26 34

prev

next

Page 41: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

40

LecturesWeek 7

Hash tables. Binary search trees. Huffman coding. Heaps. Heapsort. Tries.

Image from Data Structures & Their Algorithms.

Page 42: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

41

LecturesWeek 8

TCP/IP. HTTP. XHTML. PHP. SQL.

Page 43: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

42

LecturesWeek 9

DOM. CSS. Inheritance. JavaScript. Events, continued. OOP. Ajax.

Image from www.gearthblog.com.

Page 44: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

43

LecturesWeek 10

Preprocessing. Compiling. Assembling. Linking. CPUs.

Image from regmedia.co.uk.

Page 45: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

44

LecturesWeek 11

Enterprise architectures. Virtualization. Cloud computing. Sneak previews.

Image from amazon.com.

Page 46: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

45

LecturesWeek 12

Exciting conclusion.

Page 47: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

46

Problem Sets*Problem Set 0: ScratchProblem Set 1: CProblem Set 2: CryptoProblem Set 3: To Be NamedProblem Set 4: To Be NamedProblem Set 5: ForensicsProblem Set 6: MispellingsProblem Set 7: XHTML + PHP + SQLProblem Set 8: JavaScript

* Hacker Editions too

Page 48: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

47

Final Project*

Build something of interest to you.Make something useful.Solve an actual problem.Somehow impact campus.

* CS 50 Fair

Page 49: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

48

kthxbai

Page 50: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

49

Algorithms1) let socks_on_feet = 02) while socks_on_feet != 23) open sock drawer4) look for sock5) if you find a sock then6) put on sock7) socks_on_feet++8) look for matching sock9) if you find a matching sock then10) put on matching sock11) socks_on_feet++12) close sock drawer13) else14) remove first sock from foot15) socks_on_feet--16) else17) do laundry and replenish sock drawer

Page 51: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

50

O Hai, C!hai.c

#include <stdio.h>

int

main(int argc, char * argv[])

{printf("O hai, world!\n");

}

Page 52: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

51

O Hai, C!#include <stdio.h>

int

main(int argc, char * argv[])

{

printf("O hai, world!\n");

}10000011 00000001 00010001 00000000 00111101 11111100 01110100 0011110100000000 01000000 00000000 00000000 00000000 00000000 00000000 0000000010010000 00000000 00000000 00000000 01010000 00000000 00000111 0011000000001011 00000001 00001011 00000011 00001010 00000000 00000000 0000000000000000 00100000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00100000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000001110000 00010000 00000000 00100000 00000001 00000000 00000000 0000000000000000 00000000 00000000 00100000 00000001 00000000 00000000 0000000000000000 00000000 00000000 01000000 00000001 00000000 00000000 0000000000000000 00100000 00000000 01000000 00000001 00000000 00000000 0000000011111111 11111111 11111111 11111111 11111111 11111111 11111111 1111111110010000 10000000 00000000 01000000 00000001 00000000 00000000 0000000000101110 01100100 01111001 01101110 01100001 01101101 01101001 0110001110110000 00000100 00000000 00100000 00000001 00000000 00000000 0000000010110000 00000100 00000000 00100000 00000001 00000000 00000000 0000000010100000 00000001 00000000 00000000 00000000 00000000 00000000 0000000010110000 00000100 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00100000 00000000 00000000[...]

Page 53: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

52

O Hai, Scratch!Hai1.sb

Page 54: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

53

Statements

...

Page 55: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

54

StatementsHai{2,3}.sb

Page 56: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

55

Boolean Expressions

...

Page 57: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

56

Conditions

...

Page 58: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

57

ConditionsHai{4,5}.sb

Page 59: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

58

Loops

Page 60: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

59

LoopsHai{6,7,8}.sb

Page 61: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

60

VariablesCount{1,2}.sb

Page 62: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

61

Arrays

Page 63: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

62

ArraysFruitcraftRPG.sb

Page 64: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

63

ThreadsMove1.sb

Page 65: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

64

ThreadsMove2.sb

Page 66: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

65

ThreadsHai10.sb

Page 67: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

66

ThreadsDavid.sb

Page 68: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

67

EventsMarco.sb

Page 69: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

68

Sensorssinger.sb, Masquerade.sb, davidwu.sb, Electricity.sb

Page 70: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

69

OscartimeOscartime.sb

Page 71: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

70

OscartimeDisplaying the Instructions

Page 72: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

71

OscartimeMaking Trash Fall

Page 73: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

72

OscartimeImplementing Dragging

Page 74: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

73

OscartimeImposing a Time Limit

Page 75: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

74

OscartimeKeeping Score

Page 76: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

75

OscartimeRaising Oscar’s Lid

Page 77: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

76

int

main(int argc, char * argv[])

{

printf("O hai, world!\n");

}

Scratch Meets C

Page 78: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

77

StatementsScratch v. C

printf("O hai, world!\n");

Page 79: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

78

(x < y)

((x < y) && (y < z))

Boolean ExpressionsScratch v. C

Page 80: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

79

if (x < y)

{printf("x is less than y\n");

}

else if (x > y)

{

printf("x is greater than y\n");

}

else

{printf("x is equal to y\n");

}

ConditionsScratch v. C

Page 81: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

80

while (1)

{printf("O hai!\n");

}

for (int i = 0; i < 10; i++)

{printf("O hai!\n");

}

LoopsScratch v. C

Page 82: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

81

int counter = 0;

while (1){

printf("%d\n", counter);

counter++;

}

VariablesScratch v. C

Page 83: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

82

char *inventory[SIZE];

inventory[i] = "Orange";

ArraysScratch v. C

Page 84: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

83

Problem Set 0

Page 85: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

84

Problem Set 0HACKER EDITION

Page 86: Week 0 - CS50cdn.cs50.net/2008/fall/lectures/0/week0.pdf · 2012-08-22 · 0 Computer Science 50 Introduction to Computer Science I Harvard College David J. Malan malan@post.harvard.edu

85

Computer Science 50Introduction to Computer Science I

Harvard College

David J. [email protected]

Week 0