Anagram Maker

I need help making an anagram maker. But, the one specification is that is does not include algorithms. If you guys have anything to help me out with that would be great.
Could you just put the word into a string and repeatedly call next_permutation?
For some reason that is prohibited because my teacher says that it wouldn't quite be original. He wants us to make a "partial" anagram maker. Therefore I could possible use this right?:

#include "stdafx.h"
#include # "iostream"
#include # "string>

using namespace std;

void main()
{
string word;

cout << "Enter a word please: ";
cin >> word;
cout << endl;

sort( word.begin(), word.end() );
{
do
{
cout << word << '\n';
while( word.begin(), word.end() );

}
}
partial meaning that they don't actually have to be words
1
2
3
4
5
6
7
8
#include <iostream>
#include <algorithm>

int main(void) {
	std::string word = "pagers";
	while(next_permutation(word.begin(), word.end())) 
		std::cout << word << '\n';
}


http://en.cppreference.com/w/cpp/algorithm/next_permutation

Like Zhuge suggested, you could simply use the next_permutation function (defined in the algorithm header) to accomplish the given task. The use of the function is simple, clean and painless. Does my answer satisfy you?
Last edited on
Yes is does, thank you very much.
Topic archived. No new replies allowed.