[HNU 10058] Server

司马自明
2023-12-01
Server
Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:32768KB
Total submit users: 1391, Accepted users: 1295
Problem 10058 : No special judgement
Problem description

Users of computers frequently enter URLs (Uniform Resource Locators) in the form

protocol://server.network

For example, in the URL

http://www.monkey.donkey.zebra.com

the protocol is "http", the server is "www", and the network is "monkey.donkey.zebra.com". For purposes of this problem, the protocol and server are alphanumeric strings, whereas the network is an alphanumeric string that may also contain periods (however, the URL cannot end with a period or contain two consecutive periods).


 
Input
Each line of the input contains a URL in the format specified above. No line will be longer than 80 characters. The input is terminated by end-of-file.
 
Output
Each line of input will give rise to one line of output, consisting of the word "server", followed by a colon and one blank space, and the server from the corresponding line of input.
 
Sample Input
http://www.monkey.donkey.zebra.com
ftp://newton.cs.colorado.edu
Sample Output
server: www
server: newton

 AC:

#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>


int main()
{
    int ch; int p = 0;
    while (~(ch = getchar())) 
    {
        if (ch == '/') ++p;
        else if (ch == '.' && p == 2) printf("\n"), p = 0;
        else if (p == 2) printf("%c", ch);
        if (p == 1) printf("server: ");
    }
    return 0;
}

 

 类似资料: