Advertisement
Guest User

Five Special Letters

a guest
Jul 9th, 2014
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. class Program
  4. {
  5. static int WeightCalculation(List<int> weights)
  6. {
  7. for (int i = 0; i < weights.Count-1; i++)
  8. {
  9. for (int j = i + 1; j < weights.Count; j++)
  10. {
  11. if (weights[i] == weights[j])
  12. {
  13. weights.RemoveAt(j);
  14. j--;
  15. }
  16. }
  17. }
  18.  
  19. int weight = 0;
  20. for (int i = 0; i < weights.Count; i++)
  21. {
  22. weight += (i + 1) * weights[i];
  23. }
  24. return weight;
  25. }
  26. static void Main(string[] args)
  27. {
  28. int start = int.Parse(Console.ReadLine());
  29. int end = int.Parse(Console.ReadLine());
  30.  
  31. int counter = 0, weight;
  32. int[] weights = { 5, -12, 47, 7, -32 };
  33. char[] symbols = { 'a', 'b', 'c', 'd', 'e' };
  34.  
  35. List<int> weightsTemp = new List<int>();
  36.  
  37. for (int a = 0; a < weights.Length; a++)
  38. {
  39.  
  40. for (int b = 0; b < weights.Length; b++)
  41. {
  42.  
  43. for (int c = 0; c < weights.Length; c++)
  44. {
  45.  
  46. for (int d = 0; d < weights.Length; d++)
  47. {
  48.  
  49. for (int e = 0; e < weights.Length; e++)
  50. {
  51.  
  52. weightsTemp.Add(weights[a]);
  53. weightsTemp.Add(weights[b]);
  54. weightsTemp.Add(weights[c]);
  55. weightsTemp.Add(weights[d]);
  56. weightsTemp.Add(weights[e]);
  57.  
  58. weight = WeightCalculation(weightsTemp);
  59.  
  60. if (weight >= start && weight <= end)
  61. {
  62. counter++;
  63. Console.Write("" + symbols[a] + symbols[b] + symbols[c] + symbols[d] + symbols[e] + " ");
  64. }
  65.  
  66.  
  67. weightsTemp.RemoveRange(0, weightsTemp.Count);
  68.  
  69. }
  70.  
  71. }
  72.  
  73. }
  74.  
  75. }
  76.  
  77. }
  78.  
  79. if (counter == 0)
  80. {
  81. Console.Write("No");
  82. }
  83. }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement