fork(1) download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. public class Program
  6. {
  7. struct QA { public string Q, A; }
  8.  
  9. static Random _r = new Random();
  10. static int Quiz()
  11. {
  12. var QAndA = new QA[] {
  13. new QA { Q = "What is the capital of France" , A = "Paris"},
  14. new QA { Q = "What is the capital of Spain" , A = "Madrid"},
  15. // ...
  16. new QA { Q = "What is the captial of Russia" , A = "Moscow"},
  17. new QA { Q = "What is the capital of Ukraine" , A = "Kiev"},
  18. };
  19.  
  20. foreach (var qa in QAndA.OrderBy(i => _r.Next()))
  21. {
  22. Question(qa.Q, qa.A);
  23. }
  24.  
  25. return 0;
  26. }
  27.  
  28. public static void Main(string[] args)
  29. {
  30. int n = Quiz();
  31. }
  32.  
  33. private static void Question(string q, string a)
  34. {
  35. Console.WriteLine("Q. {0}", q);
  36. Console.WriteLine("A. {0}", a);
  37. }
  38.  
  39. }
  40.  
stdin
Standard input is empty
compilation info
prog.cs(30,21): warning CS0219: The variable `n' is assigned but its value is never used
Compilation succeeded - 1 warning(s)
stdout
Q. What is the captial of Russia
A. Moscow
Q. What is the capital of Ukraine
A. Kiev
Q. What is the capital of Spain
A. Madrid
Q. What is the capital of France
A. Paris