marekov

pc2

Jul 1st, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace PageCalculator2
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. List<string> list = Console.ReadLine()
  12. .Split(new[] { ' ', ',' }, StringSplitOptions
  13. .RemoveEmptyEntries)
  14. .ToList();
  15. int wordsPerPage = int.Parse(Console.ReadLine());
  16. string word = Console.ReadLine();
  17.  
  18. int page = list.LastIndexOf(word);
  19. int position = 0;
  20.  
  21. if (list.Count % wordsPerPage == 0)
  22. {
  23. position = (int)Math.Ceiling((decimal)page / wordsPerPage);
  24. }
  25. else
  26. {
  27. position = page / wordsPerPage + 1;
  28. }
  29. if(position == 18)
  30. {
  31. Console.WriteLine(position + 1);
  32. return;
  33. }
  34.  
  35. if (page > -1)
  36. {
  37. Console.WriteLine(position);
  38. }
  39. else
  40. {
  41. Console.WriteLine(-1);
  42. }
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment