Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. class Program
  2. {
  3. static string[] extractedwords;
  4. static string[] words;
  5. static int margin;
  6. static int n;
  7. static int k;
  8. static void Main(string[] args)
  9. {
  10. words = new string[4] { "coffee", "white", "blue", "chocolate"};
  11. Console.WriteLine("Dati n:");
  12. margin = int.Parse(Console.ReadLine());
  13. GenerateWords(1);
  14. }
  15. static void GenerateWords(int n)
  16. {
  17. if (n == margin)
  18. {
  19. return;
  20. }
  21. for (int a = 0; a < n; a++)
  22. {
  23. for (int c = 0; c < words.Length; c++)
  24. {
  25. extractedwords[a] = words[c];
  26. PrintWords(extractedwords);
  27. }
  28. GenerateWords(n + 1);
  29. }
  30. }
  31. static void PrintWords(string[] words)
  32. {
  33. for (int n = 0; n < words.Length; n++)
  34. {
  35. if (words[n] == null)
  36. {
  37. return;
  38. }
  39. Console.Write("{0} ", words[n]);
  40. }
  41. Console.WriteLine();
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement