Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. using System;
  2.  
  3. public class Program
  4. {
  5. public static void Main()
  6. {
  7. int[] a = {4,15,35,8};
  8. //int[] a = {4,19,35,43};
  9. string input = "The quick brown fox jumps over the lazy dog.";
  10. Console.WriteLine(GivenTask(input, a));
  11.  
  12. }
  13.  
  14. public static string GivenTask(string input, int[] boltIndexes)
  15. {
  16. string answer = null;
  17.  
  18. bool didItStart = false;
  19. int count = 0;
  20.  
  21. for(int i = 1; i < boltIndexes.Length; i=i+2)
  22. {
  23. boltIndexes[i] = boltIndexes[i] + boltIndexes[i-1];
  24. }
  25.  
  26. for(int i = 0; i < input.Length; i++)
  27. {
  28. if(boltIndexes[count] == i)
  29. {
  30. if(didItStart)
  31. {
  32. answer = answer + "</b>";
  33. didItStart = false;
  34. count++;
  35. }
  36. else
  37. {
  38. answer = answer + "<b>";
  39. didItStart = true;
  40. count++;
  41. }
  42. }
  43. answer = answer + input[i];
  44. }
  45.  
  46. return answer;
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement