Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
4003CEM-templates_orig/lab_algorithm.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
40 lines (31 sloc)
1 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <algorithm> | |
#include <string> | |
#include <vector> | |
/* Code should print every possible combination | |
of the values seperated by commas. | |
Make sure to research the <algorithm> library. | |
E.g. if items contains the value 3, 2, 1 then code should | |
output: | |
1, 2, 3, | |
1, 3, 2, | |
2, 1, 3, | |
2, 3, 1, | |
3, 1, 2, | |
3, 2, 1, | |
The order of the permutations does not matter although the | |
order of values in each permutation obviously does. | |
The values are supplied as command line arguments | |
when running the program. | |
I.e. bin/lab_algorithm 3 2 1 | |
*/ | |
int main( const int argc, const char *argv[] ) | |
{ | |
std::vector<std::string> items( argv+1, argv+argc ); // put the command line arguments into vector | |
std::cout << "The items are:" << std::endl; // print list of arguments | |
for( std::string &i : items ) | |
std::cout << " " << i << std::endl; | |
std::cout << "The permutations are:" << std::endl; | |
//COMPLETE ME | |
return 0; | |
} |