Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace CollectionModif
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11.  
  12.  
  13. List<int> numberlist = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 76, 78, 8, 55 };
  14. int[] numberarray = new int[10] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
  15.  
  16. foreach (int element in ModCollection.NotEvenElement(numberarray))
  17. {
  18. Console.Write(element);
  19. }
  20.  
  21. ModCollection.CollectionEvenRizor(numberlist);
  22. Console.WriteLine("");
  23. foreach (int element in numberlist)
  24. {
  25. Console.WriteLine(element);
  26. }
  27.  
  28.  
  29. // ТЕСТЫ
  30.  
  31. List<int> testlist = new List<int> { };
  32. ModCollection.CollectionEvenRizor(testlist);
  33. if (testlist.Count == 0)
  34. {
  35. Console.WriteLine("Test null List PASS");
  36. }
  37. else
  38. {
  39. Console.WriteLine("Test null List FAILED");
  40. }
  41.  
  42. List<int> testlist1 = new List<int> { 2, 2, 2, 2, 2, 2 };
  43. ModCollection.CollectionEvenRizor(testlist1);
  44. if (testlist1.Count == 0)
  45. {
  46. Console.WriteLine("Test Even List PASS");
  47. }
  48. else
  49. {
  50. Console.WriteLine("Test Even List FAILED");
  51. }
  52.  
  53. List<int> testlist2 = new List<int> { 1, 3, 5, 7, 9, 11 };
  54. ModCollection.CollectionEvenRizor(testlist2);
  55. if (testlist2.Count == 6)
  56. {
  57. Console.WriteLine("Test dont Even List PASS");
  58. }
  59. else
  60. {
  61. Console.WriteLine("Test dont Even List FAILED");
  62. }
  63.  
  64. List<int> testlist3 = new List<int> { 1 };
  65. int countbeforRizor = testlist3.Count;
  66. ModCollection.CollectionEvenRizor(testlist3);
  67. if (testlist3.Count == countbeforRizor)
  68. {
  69. Console.WriteLine("Test short dont Even List PASS");
  70. }
  71. else
  72. {
  73. Console.WriteLine("Test short dont Even List FAILED");
  74. }
  75.  
  76. List<int> testlist4 = new List<int> { 3 };
  77. ModCollection.CollectionEvenRizor(testlist4);
  78. if (testlist4[0] == 1)
  79. {
  80. Console.WriteLine("Test short Even List PASS");
  81. }
  82. else
  83. {
  84. Console.WriteLine("Test short Even List FAILED");
  85. }
  86. }
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement