Array Use

I'm not very good at c++ and I can come up with ideas for how to solve some problems but not how to put it into code.
My problem is I'm trying to write a program where a string is input and the program checks if it is a permutation of a predefined string "ABCDEFGHIJKLMNOPQRSTUVWXYZ.,' ".
Now I have already sorted it out so that it checks that the lengths of the strings are the same, now I just need to have it check that there are no duplicated characters and that the chracters in the input are only chars from rhe original
I thought about using an array, and have it see if the first character from the original string is in the input: if it isn't, the test fails; if it is but multiple times, the test fails; and if it is but only once, it then goes and does the same for the next character.
And so if it makes it to the last character of the original and there is only one then the input is a permutation.
I'm just not sure how to write the code for this, also I don't know if this would be the best way to do it, it's just the best thing I could think of.
Last edited on
Greetings !
I'm a beginner myself too. I have a bit of problem understanding your post but I think I got the slight idea of what you are saying.

My suggestion is that maybe you could input some sort of palindrome code? Since you wanted to see whether the first letter of your input matches your original string or not and so on...

I'm not really sure I've help but god speed to you !
Apologies for the rambly explanation, here's an image trying to explain what I mean (even though it's probably even worse then my written explanation) http://prnt.sc/aszzim

What I need to do is have the program test if the input string is a permutation of the predefined "alphabet" and so to test that, I can test three things:
1) that the lengths of the string's are the same
2) that the input doesn't contain any duplicate characters
3) that the input doesn't contain any characters that don't belong to the "alphabet"

So I thought of putting the "alphabet"and input into an array and check the second row (which would be the input) for each of the characters of the "alphabet" 1 by 1.
That would be probably take a long time, and there is probably a better way of going about it then using an array and checking one character at a time, for all 30 chracters of the "alphabet" 30 times.
Topic archived. No new replies allowed.