Anagram Maker

Dec 19, 2012 at 11:48pm
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.
Dec 20, 2012 at 12:55am
Could you just put the word into a string and repeatedly call next_permutation?
Dec 20, 2012 at 2:19am
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() );

}
}
Dec 20, 2012 at 2:20am
partial meaning that they don't actually have to be words
Dec 20, 2012 at 4:06am
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 Dec 20, 2012 at 4:07am
Dec 20, 2012 at 4:09am
Yes is does, thank you very much.
Topic archived. No new replies allowed.