word unscrambling and swapping variable contents

Hi there,
I'm just trying to execute the program ideas given by LacViet in this thread:

http://www.cplusplus.com/forum/beginner/3473/#msg14621

I'm having problems with 11. and 14. though:

11. Perform 4-letter WORD UNSCRAMBLING i.e. List all possible combinations of 4-letters in a word. Ex: The word 'TEST' can be unscrambled as TEST,TETS,TSET,TSTE,TTSE,TTES,etc. (Beginner)


14. Write a program to SWAP the contents of 3 variables without using the temporary (or extra) variables. (Beginner)


I would appreciate someone giving me slight (!) hints as to what I'm supposed to do.

I think in exercise 11. I will very likely need a loop that prints out the new 4-letter combinations, but thats about it :(

Exercise 14. I really have no idea on what to do (using no 4th variable to save the contents in?!)
greetings

//EDIT:
Also, is 16. the same exercise as 7.? :D
Last edited on
In exercise 11 you'll just have to "play with it" a bit.
In exercise 14, probably the xor operator will be useful to you. At least it used to be with 2-var swapping without a third variable. Or didn't it?
I'll first try my luck with 14. but I still don't get in which way the xor operator would be of any use here :S I mean I can only recognize whether the 3 variables are different from each other with it, right?

//EDIT:
Thought about 11. again and wrote something similar to what I had earlier:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
using namespace std;
#include <string>

int main(){
	string word;
	string copy;
	cin >> word;
	copy=word;
	for(int a=0; a!=word.size()-1; a++){
		word[a]=copy[a+1];
	}
	cout << word;
	return 1;
}


so if i input
abcd

I would get
bcdd

Can't the for loop somehow when it detects it hit the end of the copy string start over in the beginning?

This would only be the first scrambled letter combination and I'm already failing on it -.-
Last edited on
No help? :(
I've got a solution if you want it.
I'm rather looking for hints than the full solution but maybe you can post a link to the code so I can't see it immediately when you post it ^^

Anyways, does anybody know a teamspeak or something like that (or a tutor) where I can get some help with C++ because I'm really lost right now -.-
Last edited on
No worries, here's a codepad link (not sure how long it stays up). http://codepad.org/hwzqQJ9P

Instead of just doing it for four letter words, I've modified it so the user can enter whatever length they like at the start of the program.

I used a standard algorithm to find the permutations.
22. Develop a animal classification program base on the animal kingdom. (for practice the use of inhabitant classes).


Can someone explain to me what I'm supposed to do in this exercise? The program is supposed to categorize the animal based on my input, or should I just write classes (like class reptile{})? Also, what are "inhabitant classes"?
Topic archived. No new replies allowed.