Skip to content

Instantly share code, notes, and snippets.

@EvanHahn
Created September 14, 2012 18:24
Show Gist options
  • Save EvanHahn/3723731 to your computer and use it in GitHub Desktop.
Save EvanHahn/3723731 to your computer and use it in GitHub Desktop.
EECS 281 discussion 1 notes

C++ I/O

  • cin.get

  • cin.unget

  • getline(cin, var)

  • cin >> var

  • cout is slow because it has to go to the operating system

  • To have good speed, use internal buffers. Use ostringstream to build it up, build it up, and then when you're done, finally do only one cout: cout << myStringStream.str()

getopt

  • Helps you deal with command line arguments and options.

  • Arguments versus options: ls -a has -a as an argument, cd hi has hi as an argument

  • Passing argc and argv to getopt to the function, it helps you

  • getopt has a website and the slides have stuff too

  • getopt_long you can have things like --help; words, rather than just single-character ones

Complexity

  • O(g(n)) = f(n) if g(n) is an upper bound to f(n)

  • Big omega means the worst case

  • Big theta means that the upper bound and lower bound are the same thing

  • 2x^4 + 2x = O(x^4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment