2 thus only we will make fun 2 13 this is cs50 harvard

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: our own, you can also search for or browse answers to questions already asked by others. And never fear asking “dumb questions.” Students’ posts to the course’s bulletin board are anonymized. Only the staff, not fellow students, will know who you are!2 And, of course, there are plenty of office hours: http://www.cs50.net/ohs/. 1 Note that there’s a space between pset3 and that last tilde (~), the latter of which, recall, represents your home directory. 2 Thus, only we will make fun. 2 < 13 This is CS50. Harvard College Fall 2010 Find. Now let’s dive into the first of those subdirectories. Execute the command below. cd ~/hacker3/find If you list the contents of this directory, you should see the below. helpers.c helpers.h Makefile find.c generate.c Wow, that’s a lot of files, eh? Not to worry, we’ll walk you through them. Implemented in generate.c is a program that uses rand to generate a whole bunch of pseudorandom numbers, one per line. (Remember rand from Problem Set 1?) Go ahead and compile this program by executing the command below. make generate Now run the program you just compiled by executing the command below. ./generate You should be informed of the program’s proper usage, per the below. Usage: generate n [s] As this output suggests, this program expects one or two command ­line arguments. The first, n, is required; it indicates how many pseudorandom numbers you’d like to generate. The second, s, is optional, as the brackets are meant to imply; if supplied, it represents the value that the pseudorandom ­number generator should use as its seed. (Remember from Problem Set 1 what a seed is?) Go ahead and run this program again, this time with a value of, say, 10 for n, as in the below; you should see a list of 10 pseudorandom numbers. ./generate 10 Run the program a third time using that same value for n; you should see a different list of 10 numbers. Now try running the program with a value for s too (e.g., 0), as in the below. ./generate 10 0 Now run that same command again: ./generate 10 0 Bet you saw the same “random” sequence of ten numbers again? Yup, that’s what happens if you don’t vary a pseudorando...
View Full Document

Ask a homework question - tutors are online