zoukankan      html  css  js  c++  java
  • hdu 4018 Parsing URL(水题)

    Parsing URL

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)
    Total Submission(s): 520    Accepted Submission(s): 321


    Problem Description
    In computing, a Uniform Resource Locator or Universal Resource Locator (URL) is a character string that specifies where a known resource is available on the Internet and the mechanism for retrieving it.
    The syntax of a typical URL is:
    scheme://domain:port/path?query_string#fragment_id
    In this problem, the scheme, domain is required by all URL and other components are optional. That is, for example, the following are all correct urls:
    http://dict.bing.com.cn/#%E5%B0%8F%E6%95%B0%E7%82%B9
    http://www.mariowiki.com/Mushroom
    https://mail.google.com/mail/?shva=1#inbox
    http://en.wikipedia.org/wiki/Bowser_(character)
    ftp://fs.fudan.edu.cn/
    telnet://bbs.fudan.edu.cn/
    http://mail.bashu.cn:8080/BsOnline/
    Your task is to find the domain for all given URLs.
     

    Input
    There are multiple test cases in this problem. The first line of input contains a single integer denoting the number of test cases.
    For each of test case, there is only one line contains a valid URL.
     

    Output
    For each test case, you should output the domain of the given URL.
     

    Sample Input
    3 http://dict.bing.com.cn/#%E5%B0%8F%E6%95%B0%E7%82%B9 http://www.mariowiki.com/Mushroom https://mail.google.com/mail/?shva=1#inbox
     

    Sample Output
    Case #1: dict.bing.com.cn Case #2: www.mariowiki.com Case #3: mail.google.com
     

    Source
     

    Recommend
    lcy
     
     
    #include<stdio.h>
    #include<string.h>
    #include<iostream>
    using namespace std;
    char str[5000];
    char tt[5000];
    int main()
    {
    int T;
    int iCase=0;
    bool start;
    int i;
    scanf("%d",&T);
    while(T--)
    {
    iCase++;
    scanf("%s",&str);
    start=false;
    int len=strlen(str);
    int t=0;
    for(i=2;i<len;i++)
    {
    if(start==false&&str[i-2]==':'&&str[i-1]=='/'&&str[i]=='/') {start=true;continue;}
    if(start&&(str[i]=='/'||str[i]==':')) break;
    if(start) tt[t++]=str[i];
    }
    tt[t]='\0';
    printf("Case #%d: %s\n",iCase,tt);

    }
    return 0;

    }
  • 相关阅读:
    使用SpringBoot校验客户端传来的数据
    在RestController中获取各种信息的方法
    SpringBoot的文件上传&下载
    Maximum upload size exceede上传文件大小超出解决
    在SpringBoot程序中记录日志
    使用IDEA配置SpringBoot热部署无效解决
    RESTful API是什么?
    IDEA如何配置jdk路径
    使用IDEA集成Spring框架时右下角警戒
    Spring框架各模块功能介绍
  • 原文地址:https://www.cnblogs.com/kuangbin/p/2198937.html
Copyright © 2011-2022 走看看