Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace practice9
  8. {
  9. class Program
  10. {
  11. public static int ReadNatural()
  12. //ввод числа для красивых лаб
  13. {
  14. bool check = false;
  15. int intNum;
  16. do
  17. {
  18. // Попытка перевести строку в число
  19. check = Int32.TryParse(Console.ReadLine(), out intNum);
  20. // Если попытка неудачная:
  21. if (!check)
  22. Console.WriteLine("Некорректный ввод. Попробуйте ещё раз");
  23. } while (!check);
  24. // Если попытка удачная:
  25. return intNum;
  26. }
  27. static Random rnd = new Random();
  28. static void Main(string[] args)
  29. {
  30. CircleList<int> circleList = new CircleList<int>();
  31. Console.WriteLine("Введите количество элементов которые необходимо добавить в список");
  32. int n=ReadNatural();
  33. for( int i=0; i<n;i++)
  34. {
  35. circleList.Add(rnd.Next(-100, 101));
  36. }
  37. Node<int> point = new Node<int>(0);
  38. for (int i = 0; i < circleList.Count; i++)
  39. {
  40. Console.Write(point.Data + " ");
  41. point = point.Next;
  42. }
  43.  
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement