words in C#

Started by
6 comments, last by rob64464 20 years ago
Hello, I have a complicated question that I am stuck on in C#. I have been attempting to fix this but no good. So I’ll explain best I possibly can: I have a string say String one = “drmeaer” String two = “daydreamer” What I want to do is when you press a button called arrange then it will produce an output of: ???dreamer //notice that the ??? are for day. How would I do that? I really am stuck the strings maybe different as well each time. Does anybody have any solutions? Thank You, Rob
Advertisement
You should give more details, because what you want to accomplish is quite blurry. Give us maybe more context too.
do you want the words to be chosen randomly
string2 is subject to change so yeah string2 is completely random. string1 is where you guess random letters that are in the word. They are defintley in the word so you won''t get for daydream the word u or v or anyother word which is in daydreamer. All I really want to do is spell the word out if you have the letters else put a ? mark there.
How do you know which letter to reveal if there are multiple matches? Why is the output ???dreamer and not d???reamer or da??re?mer?
I think that if the word is daydreamer, and the guess is ''D'', it should reveal both Ds, ie. d??d??????.

---
shurcooL`
yes guys sorryt. I should have released yes you do get two d''s it will look like this

d??dreamer. Sorry that was my bad maths. So any soloutions then? Its really anyoing me now
Initialize string three: ""For a: each char in string two  Initialize flag: false  For b: each char in string one    If char a of string two == char b of string one      flag = true  If flag    append char a of string two to string three  else    append "?" to string threeOutput string three 


Conversion to C# is left as an exercise for the reader. There are also plenty of possible optimizations I''m sure.

This topic is closed to new replies.

Advertisement