Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace בגרות_2003_תרגיל_8
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. string strBefore;
  13. string strAfter;
  14. int count = 1;
  15. char ch;
  16. string strCh;
  17.  
  18. Console.WriteLine("Input a phrase no longer than 120 characters:");
  19. strBefore = Console.ReadLine();
  20. strAfter = strBefore;
  21.  
  22. for (int i = 0; i < strBefore.Length - 1; i++)
  23. {
  24. if (strBefore[i] < 'M' && strBefore[i] >= 'A')
  25. {
  26. ch = strBefore[i];
  27. ch++;
  28. strCh = ch.ToString();
  29.  
  30. strAfter = strAfter.Insert(i + count, strCh);
  31.  
  32. count++;
  33. }
  34. else if (strBefore[i] >= 'M' && strBefore[i] <= 'Z')
  35. {
  36. ch = strBefore[i];
  37. ch--;
  38. strCh = ch.ToString();
  39.  
  40. strAfter = strAfter.Insert(i + count, strCh);
  41.  
  42. count++;
  43. }
  44. else if (strBefore[i] == ' ')
  45. {
  46. strAfter = strAfter.Replace(" ", "");
  47. }
  48. }
  49.  
  50. Console.WriteLine();
  51. Console.WriteLine(strAfter);
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement