Strings.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.Specialized;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace ConsoleAppForGit
  8. {
  9. internal class Strings
  10. {
  11. public string? str = Console.ReadLine();
  12. void FirstTask(string str)
  13. {
  14. string strFinish = "";
  15. int len = str.Length;
  16. int i = 0;
  17. while (i < len)
  18. {
  19. if (i % 2 == 0)
  20. {
  21. strFinish = strFinish + str[i];
  22. }
  23. }
  24. Console.WriteLine(strFinish);
  25. }
  26. void NinethTask(string str)
  27. {
  28. string strFinish = "";
  29. string strEvenFinish = "";
  30. int len = str.Length;
  31. int i = 0;
  32. while (i < len)
  33. {
  34. if (i % 2 == 0)
  35. {
  36. strFinish = strFinish + str[i];
  37. }
  38. }
  39. while (i < len)
  40. {
  41. if (i % 2 != 0)
  42. {
  43. strEvenFinish = strEvenFinish + str[i];
  44. }
  45. }
  46. Console.WriteLine(strFinish);
  47. Console.WriteLine(strEvenFinish);
  48. }
  49. }
  50. }