ACM (TJU) : 1593


/package volume_VI;

import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		Scanner input = new Scanner (System.in);
		
		int n = input.nextInt();
		String s = input.nextLine();
		int testCase = 0;
		
		while ( n -- != 0 ) {
			
			s = input.nextLine();
			
			System.out.println ("URL #" + (++testCase));
			System.out.print ("Protocol = ");
			
			int index = 0;
			while ( s.charAt(index) != ':')
				System.out.print(s.charAt(index++));
			System.out.println ();
			
			index += 3;
			System.out.print ("Host     = ");
			if ( index < s.length()) {
				while (  index < s.length() && s.charAt(index) != ':' && s.charAt(index) != '/')
					System.out.print(s.charAt(index++));
				System.out.println ();
			}
			else
				System.out.println ("<default>");
			
			if ( index == s.length() || s.charAt(index) == '/')
				System.out.println ("Port     = <default>");
			else {
				System.out.print ("Port     = ");
				index++;
				while ( index < s.length() && s.charAt(index) != '/')
					System.out.print(s.charAt(index++));
				System.out.println ();
			}
			
			index++;
			if ( index < s.length()) {
				System.out.print ("Path     = ");
				while ( index < s.length())
					System.out.print(s.charAt(index++));
				System.out.println ();
			}
			
			else
				System.out.println ("Path     = <default>");
			
			System.out.println ();
			
		}

	}

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s