Advertisement
desislava_topuzakova

3. Обръщане на низ

Mar 25th, 2023
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _03._Reverse_String
  4. {
  5. internal class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. //"Pesho" -> "ohseP"
  10.  
  11. String text = Console.ReadLine();
  12.  
  13. //обхождане на символите от първия към последния
  14. /*for (int index = 0; index <= text.Length - 1; index++)
  15. {
  16. Console.WriteLine(text[index]);
  17. }*/
  18.  
  19. //символи от последния (дължина - 1) към първия (0)
  20. for (int index = text.Length - 1; index >= 0; index--)
  21. {
  22. Console.Write(text[index]);
  23. }
  24. }
  25. }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement