HDU4018 Parsing URL【水题】
来源:互联网 发布:超融合云计算 编辑:程序博客网 时间:2024/06/18 07:49
Parsing URL
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 1837 Accepted Submission(s): 920
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.
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.
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
3http://dict.bing.com.cn/#%E5%B0%8F%E6%95%B0%E7%82%B9http://www.mariowiki.com/Mushroomhttps://mail.google.com/mail/?shva=1#inbox
Sample Output
Case #1: dict.bing.com.cnCase #2: www.mariowiki.comCase #3: mail.google.com注意结果是在//和 :or/ 之间.#include<stdio.h>#include<string.h>char url[1010];int main(){int t;int i,k=1,m;scanf("%d",&t);while(t--){m=0;scanf("%s",url);for(i=0;url[i]!='\0';i++){if(m==0&&url[i]=='/'){m=i+2;i++;continue;}if(m!=0&&url[i]==':'||url[i]=='/'){url[i]='\0';break;}}printf("Case #%d: ",k);k++;printf("%s\n",url+m);}return 0;}
0 0
- HDU4018 Parsing URL【水题】
- HDU4018:Parsing URL
- hdu4018 Parsing URL
- hdu2072 单词数 和 hdu4018 Parsing URL
- hdu4018
- hdu4018
- Parsing URL
- Parsing URL
- URL Parsing
- hdu 4018 Parsing URL
- HDU--4018(Parsing URL)
- hdu 4018 Parsing URL
- HDU 4018 Parsing URL
- hdu 4018 Parsing URL
- HDU 4018 Parsing URL
- hdu 4018 Parsing URL
- HDU 4081-Parsing URL(水)
- hdu4018字符串
- 从Java类初始化,来看代码优化
- 应届生面试,你准备好了吗?
- js取两个数组的交集
- POJ 2777-Count Color(线段树_区间染色)
- Android遇上打印机
- HDU4018 Parsing URL【水题】
- Win8 Metro(C#)数字图像处理--2.46图像RGB分量增强效果
- [后缀数组+dp/AC自动机+dp+线段树] hdu 4117 GRE Words
- 我们再也看不到“Win 10 破解版下载”
- 报表数据源之多结果集
- 史上最全设计模式导学目录(完整版)
- Java网络编程从入门到精通(23):HTTP消息头字段
- ORACLE9i_性能调优基础二(Database Configuration and IO Issues)
- vivado2014.2 zedboard 自制IP注意事项