+ 2

How do u create a random letter generator that can choose any letter from A-C except the letter chosen by the user?? Pls help.C#

Its C#

12th May 2020, 1:26 AM
Man of PEACE
Man of PEACE - avatar
3 Antworten
+ 3
Man of PEACE can you clarify ? Are you saying that no matter what the user inputs you want a completely different letter to appear ?
12th May 2020, 1:35 AM
BroFar
BroFar - avatar
+ 2
Yes, for instance if choose B the random generator can choose any letter between A & C but not B
12th May 2020, 1:36 AM
Man of PEACE
Man of PEACE - avatar
+ 1
var l = new List<string>{ "A","B","C"}; string ans = Console.ReadLine(); int i = l.IndexOf(ans); var rand = new Random(); int ri; do { ri = rand.Next(l.Count); } while (i == ri); Console.WriteLine(l[ri]);
12th May 2020, 1:52 AM
ChaoticDawg
ChaoticDawg - avatar