Advertisement
PetarNeshkov5360

09. Pokemon Don't Go,C# Fundamentals

Aug 16th, 2020
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ConsoleApp9
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11.  
  12. List<int> list = Console.ReadLine().Split().Select(int.Parse).ToList();
  13. List<int> DeletedNumbers = new List<int>();
  14. while (list.Count!=0)
  15. {
  16. bool check = true;
  17. int index = int.Parse(Console.ReadLine());
  18. int NumberIndex =0;
  19.  
  20.  
  21. if (index<0)
  22. {
  23. //DeletedNumbers.Add(list[0]);
  24. list.RemoveAt(0);
  25. list.Insert(0,list[list.Count - 1]);
  26. }
  27. else if (index>list.Count-1)
  28. {
  29. //DeletedNumbers.Add(list[list.Count - 1]);
  30. list.RemoveAt(list.Count - 1);
  31. list.Add(list[0]);
  32. }
  33. if (index > list.Count-1)
  34. {
  35. NumberIndex = list[list.Count - 1];
  36. index =list.Count - 1;
  37. check = false;
  38. }
  39. else if (index<0)
  40. {
  41. NumberIndex = list[0];
  42. index = 0;
  43. check = false;
  44. }
  45. else
  46. {
  47.  
  48. NumberIndex = list[index];
  49. }
  50. for (int i = 0; i < list.Count; i++)
  51. {
  52. if (list[i]<=NumberIndex)
  53. {
  54. list[i] += NumberIndex;
  55. }
  56. else if (list[i]>NumberIndex)
  57. {
  58. list[i] -= NumberIndex;
  59. }
  60. }
  61. DeletedNumbers.Add(NumberIndex);
  62. if (check==true)
  63. {
  64. list.RemoveAt(index);
  65. }
  66. }
  67. double sum = DeletedNumbers.Sum();
  68. Console.WriteLine(sum);
  69.  
  70. }
  71. }
  72. }
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement