Advertisement
Guest User

Untitled

a guest
Jun 7th, 2016
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. public class Program
  8. {
  9. public static void Main()
  10. {
  11. string input = Console.ReadLine();
  12. var firstPart = input.IndexOf("://");
  13. if (firstPart>0)
  14. {
  15. string protocol = input.Substring(0, firstPart);
  16.  
  17. if (input.Substring(firstPart+3).Contains("/"))
  18. {
  19. var secondPart = input.IndexOf("/", firstPart+3);
  20. string server = input.Substring(firstPart+3, secondPart-firstPart-3);
  21.  
  22. string resourse = input.Substring(secondPart+1);
  23.  
  24. Console.WriteLine("[protocol] = \"{0}\"", protocol);
  25. Console.WriteLine("[server] = \"{0}\"", server);
  26. Console.WriteLine("[resource] = \"{0}\"", resourse);
  27. }
  28. else
  29. {
  30. string server = input.Substring(firstPart+3);
  31. Console.WriteLine("[protocol] = \"{0}\"", protocol);
  32. Console.WriteLine("[server] = \"{0}\"", server);
  33. Console.WriteLine("[resource] = \"\"");
  34. }
  35. }
  36. else if (firstPart <=0)
  37. {
  38.  
  39. string server = input.Substring(0);
  40.  
  41. Console.WriteLine("[protocol] = \"\"");
  42. Console.WriteLine("[server] = \"{0}\"", server);
  43. Console.WriteLine("[resource] = \"\"");
  44. }
  45.  
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement