HDU 4081-Parsing URL(水)
来源:互联网 发布:软件里程碑计划模板 编辑:程序博客网 时间:2024/06/14 19:26
Parsing URL
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 1575 Accepted Submission(s): 796
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训练一下快速找到水题并切掉的能力。。毕竟现场赛只能做水题了。。7分钟1A#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include <string>#include <vector>#include <cmath>#include <map>using namespace std;#define LL long longchar s[10010],ans[10010];int main(){//ios::sync_with_stdio(false);int t,p,cas=1;scanf("%d",&t);getchar();while(t--){gets(s);int len=strlen(s);for(int i=0;i<len;i++){if(s[i]=='/'&&s[i-1]=='/'){int j=i+1;p=0;while(s[j]!='/'&&s[j]!=':')ans[p++]=s[j++];break;}}printf("Case #%d: ",cas++);for(int i=0;i<p;i++)printf("%c",ans[i]);puts("");}return 0;}
1 0
- HDU 4081-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 4018 Parsing URL
- Parsing URL
- Parsing URL
- URL Parsing
- HDU4018:Parsing URL
- hdu4018 Parsing URL
- HDU4018 Parsing URL【水题】
- hdu B. Code Parsing
- HDU 4018 Parsing URL 正则表达式 The 36th ACM/ICPC Asia Regional Shanghai Site —— Warmup
- hdu2072 单词数 和 hdu4018 Parsing URL
- 杭电OJ第4018题 Parsing URL
- Git GitHub初学
- C++笔试题深度分析 第五波 下
- 用MapReduce进行数据密集型文本处理 – 本地聚合(下)
- JAVA核心技术学习——流与文件(3.字符集)
- php_shell
- HDU 4081-Parsing URL(水)
- 习题1.16
- 用 Hadoop 计算共生矩阵
- 标准IO库、系统数据文件和信息 - UNIX环境高级编程-第5、6章
- C++实现求字符串的所有的组合
- Fedore解决双显卡切换与驱动问题
- Unique Paths
- 通过spring context和spring MVC context获取bean实例
- MapReduce算法 – 反转排序(Order Inversion)