Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbrush committed Feb 15, 2014
1 parent eeec0a7 commit d38043a
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 0 deletions.
Binary file added examples/a.out
Binary file not shown.
29 changes: 29 additions & 0 deletions examples/timing.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <iostream>
#include <chrono>

// Recursive fibonacci sequence, this should take a while.
uint64_t recursive_fib_seq(int x) {
if (x == 0 || x == 1) return x;
return recursive_fib_seq(x-1) + recursive_fib_seq(x-2);
}
//
int main (int argc, char *argv[]) {
//
// // gets the current time (starting time). Do this before your code that you want to time.
std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now();
//
// // Code that you want to time.
std::cout << "Getting the fib sequence for of 40\n";
std::cout << "Result was: " << recursive_fib_seq(40) << std::endl;
// // End of the code that you want to time.
//
// // Gets the new current time (ending time). Do this after the code you want to time.
std::chrono::high_resolution_clock::time_point stop = std::chrono::high_resolution_clock::now();
// // calculates the difference in time in between start and stop. duration<double> calculates time in seconds.
std::chrono::duration<double> time_span = std::chrono::duration_cast<std::chrono::duration<double> >(stop - start);
//
// // .count returns the time in seconds.
std::cout << "It took me " << time_span.count() << " seconds." << std::endl;

return 0;
}
Binary file added learning/a.out
Binary file not shown.
10 changes: 10 additions & 0 deletions learning/helloworld.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// a hello world program for c++

#include <iostream>
//using namespace std;

int main() {
std::cout << "Hello, world!\n";

return 0;
}
11 changes: 11 additions & 0 deletions learning/input.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <iostream>
using namespace std;

int main() {
int x;
cin >> x;

cout << x / 3 << ' ' << x * 2;

return 0;
}
10 changes: 10 additions & 0 deletions learning/variables.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <iostream>
using namespace std;

int main() {
int x;
x = 4 + 2;
cout << x / 4 << ' ' << x * 2;

return 0;
}

0 comments on commit d38043a

Please sign in to comment.