fork(4) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace test
  7. {
  8. class Letter
  9. {
  10. public char letter;
  11. public string nextLetters;
  12.  
  13. public Letter(char c, string l)
  14. {
  15. letter = c;
  16. nextLetters = l;
  17. }
  18. }
  19.  
  20. class Program
  21. {
  22. static void Main(string[] args)
  23. {
  24. List<Letter> letters = new List<Letter>();
  25. List<string> names = new List<string> {"NATALIA", "MARTA", "MONIKA", "JOANNA", "PAULINA", "PATRYCJA"};
  26. string daughterName = string.Empty;
  27. char randomLetter;
  28. int random = 5;
  29.  
  30. foreach (var name in names)
  31. {
  32. for (int i = 0; i < name.Length; i++)
  33. {
  34. if (i < name.Length - 2)
  35. letters.Add(new Letter(name[i], string.Format("{0}{1}", name[i + 1], name[i + 2])));
  36. else if(i < name.Length - 1)
  37. letters.Add(new Letter(name[i], string.Format("{0}", name[i + 1])));
  38. }
  39. }
  40.  
  41. random = (new Random((int)DateTime.Now.Ticks).Next(1, letters.Count));
  42. randomLetter = letters[random - 1].letter;
  43. daughterName += letters[random - 1].nextLetters;
  44.  
  45. foreach (var letter in letters)
  46. {
  47. if (daughterName.Length > 7 || daughterName[daughterName.Length - 1] == 'A')
  48. break;
  49.  
  50. if (daughterName[daughterName.Length - 1] == letter.letter)
  51. daughterName += letter.nextLetters;
  52.  
  53. }
  54.  
  55. Console.Write(daughterName);
  56. Console.ReadKey();
  57. }
  58. }
  59. }
  60.  
Success #stdin #stdout 0.04s 33976KB
stdin
Standard input is empty
stdout
ANATALIA