高分求助面试题目 用STL编写多线程问题
Description:
Write a command-line program BASE64.EXE that takes as input 3 variables: the input folder, the output folder, and the number of threads to use. Example:
BASE64 C:\B64\SOURCE C:\B64\DEST 2
This asks the program to read all the files from the C:\B64\SOURCE folder, convert them using base64 encoding, and write the results to the C:\B64\DEST folder. The program would use 2 threads to process 2 files at once. This allows the program to execute faster on multi-processor machines.
(In actual practice, the base64 conversion is not very computation-intensive, so the bottleneck is likely to be the input/output rather than CPU time, but for many algorithms this would be an important approach to follow.)
Framework/environment:
Please use the standard C++ library wherever possible, including the STL (Standard Template Library). The program
should run on Windows 9x, XP, Vista, etc.
You can use the Boost libraries as well, and/or WIN32 functions to create threads and mutexes, as well as for file
directory functions. Do not use MFC, .NET, or any other large frameworks.
Use object-oriented programming, and any common design patterns that might be appropriate. For example, the “thread pool pattern” is an ideal pattern to use to have the algorithm use a variable number of threads.
Notes:
Ensure that your compiler is set to link to a multithreaded version of the library.
The program does not need a GUI. Your compiler/linker must be set to make a command-line program.
The best form of documentation is a clear class structure, and well chosen names.
Please submit source code files, including tests, and any other files used.
There are many descriptions of base64 encoding on the internet. e.g. see
http://users.aber.ac.uk/jjr6/material/base64/base64.pdf
Collaboration:
The team members should analyse the problem together and determine how to break up the work into component parts.
Ideally, each part should be testable independently of the others.
One possible way to break up the work would be to assign:
Programmer 1: write & test the classes/functions to find the files & do the base64 conversion
Programmer 2: write & test the thread pooling classes
Programmer 3: write & test the main program that combines the work of the other two programmers, including validation & error-handling.
The thread pooling is the most conceptually difficult part and should be designed together.
If, after putting everything together, you see opportunities for improvement, please take the time to refactor the code.
You can use your existing tests to ensure that the code is still working as originally intended.
[解决办法]
base54 :)
[解决办法]
- -! 打错字啊
[解决办法]
http://tag.csdn.net/tag/base64/
[解决办法]
人家告诉你了, 重点不在base64 encoding, 而在thread pooling呀!
[解决办法]
面试,还是诚实点吧,会就自己写,不会就算了...
[解决办法]
这个是面试题? 我怎么看是个大作业?:)
[解决办法]
关注中