Advertisement
desislava_topuzakova

03. Digits, Letters and Others

Mar 17th, 2024
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. namespace _01._Vet_Clinic;
  2. class Program
  3. {
  4. static void Main(string[] args)
  5. {
  6.  
  7. string text = Console.ReadLine(); //"Agd#53Dfg^&4F53"
  8.  
  9. string digitsText = ""; //съхраняваме всички символи, които са цифри
  10. string lettersText = ""; //съхраняваме всички символи, които са букви
  11. string othersText = ""; //съхраняваме всички останали символи
  12.  
  13. foreach (char symbol in text) //"Agd#53Dfg^&4F53"
  14. {
  15. if (char.IsDigit(symbol))
  16. {
  17. digitsText += symbol;
  18. }
  19. else if (char.IsLetter(symbol))
  20. {
  21. lettersText += symbol;
  22. }
  23. else
  24. {
  25. othersText += symbol;
  26. }
  27. }
  28.  
  29. Console.WriteLine(digitsText);
  30. Console.WriteLine(lettersText);
  31. Console.WriteLine(othersText);
  32.  
  33.  
  34.  
  35.  
  36.  
  37. }
  38. }
  39.  
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement