CMPSC 16 Lecture Notes - Lecture 14: Binary Search Algorithm

30 views2 pages
4 Dec 2018
School
Course
Professor

Document Summary

To generate random numbers, need to include the library Use the command rand()" to generate a random number. Std:: scope operator: have to use when the using namespace std;" is not used or when writing functions that are already in the standard namespace. Rand() % 100 : returns a random number from 1 - 99. If you want the random numbers to be different each time, then you have to seed the random number generator each time differently. The seed is what is used to generate the sequence of random numbers. Usually use the time to seed the random number generator because time always changes. Have to import the in order to use the time. When you define using the standard library, it becomes an object. Using auto (c++11), then the loop figures out the type that it is. To compile using c++11, use the command g++ --std=c++11 filename".

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents