C++ Burlingame Robotics Programming Training 1
C++ Burlingame Robotics Programming Training 1
Do keep in mind that the internet is available for you to search. Dont search for the solutions to
the problems, search for the individual pieces that form the solution, i.e. how to use a conditional
within a for loop, not how to nd primes from 1-100. Youll be wasting your time if you nd
complete solutions.
Write a program that generates a vector of all the primes from 11,000,000, and outputs them to a .txt le, one per line.
Youll need to know how to use:
everything from above
std::ofstream textFile("muhprimes.txt");
ofstream (part of fstream)
textFile << "2 3 5 7 9 11 13\n";
escaped characters (\n)
Notice how outputting to a text le looks strangely similar to outputting to the
terminal. Perhaps there is a reason why the angle brackets point towards textFile and
cout.
You may run into trouble with the size of integers, and your program may take more
than one second to execute. Nothing that cant be solved with the Sieve of Eratosthenes, no doubt.
Name-replacer
Write a program that parses a le that contains an excerpt from your favorite book,
and replace every instance of the main characters name with your name.
Youll need to know how to:
parse command line args (int argc, char *argv[])
input from a le and output to a le (std::ifstream, std::ofstream)
parse strings (std::string)
1
continued.