Advertisement
Guest User

Untitled

a guest
Aug 19th, 2014
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 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. using System.Text.RegularExpressions;
  7. using System.Numerics;
  8.  
  9. class Exam
  10. {
  11. static void Main()
  12. {
  13. string letters = Console.ReadLine();
  14. int oddJump = int.Parse(Console.ReadLine());
  15. int evenJump = int.Parse(Console.ReadLine());
  16. letters = letters.ToLower();
  17. letters = Regex.Replace(letters, "\\s+", "");
  18. int[] odd = new int[letters.Length / 2];
  19. int[] even = new int[letters.Length / 2];
  20. BigInteger resultodd = 0;
  21. BigInteger resulteven = 0;
  22. int counter = 0;
  23. int counter1 = 0;
  24. if ((oddJump>1&evenJump>1)&(oddJump<=100&evenJump<=100))
  25. {
  26. for (int i = 0, k = 0, j = 1; i < letters.Length; k++, i += 2, j += 2)
  27. {
  28. odd[k] = letters[i];
  29. even[k] = letters[j];
  30. }
  31. for (int o = 0, e = 1; o < odd.Length; o++, e++)
  32. {
  33.  
  34. if (e % oddJump == 0)
  35. {
  36. resultodd *= odd[o];
  37. o++;
  38. e++;
  39. }
  40. if (o == odd.Length)
  41. {
  42. break;
  43. }
  44. resultodd += odd[o];
  45. }
  46. for (int o = 0, e = 1; o < even.Length; o++, e++)
  47. {
  48.  
  49. if (e % evenJump == 0)
  50. {
  51. resulteven *= even[o];
  52. o++;
  53. e++;
  54. }
  55. if (o == even.Length)
  56. {
  57. break;
  58. }
  59. resulteven += even[o];
  60. }
  61.  
  62. Console.WriteLine("Odd: {0:X}", resultodd);
  63. Console.WriteLine("Even: {0:X}", resulteven);
  64. }
  65.  
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement