fork(1) download
  1. using System;
  2. using System.Text;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. char[] true_false = new char[2]{'V','F'};
  9. Random rand = new Random();
  10. var generate_code = new StringBuilder();
  11. int lenght_of = 5;
  12.  
  13. for(int i =0; i < 10;i++) {
  14. generate_code.Append(generateCodeWithLength(rand, true_false, lenght_of));
  15. Console.WriteLine(generate_code);
  16. generate_code.Remove(0, generate_code.Length);
  17. } //Output expected: "FF" "VV" "FV" "VF" "FF"
  18. }
  19.  
  20. public static string generateCodeWithLength(Random rand, char[] true_false, int length) {
  21. var result = new StringBuilder(length);
  22.  
  23. for (var i = 0; i < length; i++) {
  24. result.Append(true_false[rand.Next(0, 2)]);
  25. }
  26.  
  27. return result.ToString();
  28. }
  29. }
Success #stdin #stdout 0.02s 33864KB
stdin
Standard input is empty
stdout
VFFVV
VVVFF
FFFFV
VFFVV
VVVFV
FFVFV
FVFFF
FVVFV
VVFVF
VVVFF