网址分析

xiaoxiao2021-02-28  52

题目描述 在互联网上,采用网址(URL)来标识网页等信息资源的访问地址。在比较简单的情况下,网址的格式为:  传输协议://主机/路径  常用的传输协议包括http 、ftp 、mms 、rtsp 等,主机采用域名或IP地址的形式描述,如www.zwu.edu.cn 、10.60.64.94  路径表示资源在主机上存储的具体位置(为一个目录或文件)  例如,在基础学院简介 http://jcxy.zwu.edu.cn/603/list.htm 的网址中,传输协议为http,主机是一个域名jcxy.zwu.edu.cn,  而百度首页 https://www.baidu.com/ 的网址中,传输协议为https,是安全的http传输协议,主机则是www.baidu.com 输入 输入一个网址,单行,长度不超过80,以\n结束,此外不包含其他无关的内容 输出 输出网址中的传输协议和主机(域名或IP地址)信息  样例输入 http://jcxy.zwu.edu.cn/603/list.htm http://10.60.64.94/ https://www.baidu.com/ 样例输出 http jcxy.zwu.edu.cn http 10.60.64.94 https

www.baidu.com

#include<iostream> #include<cstdio> #include<cstring> using namespace std; int main() { char sh[80]; int n,k=1; while(cin>>sh) { char ah[7],bh[80]; int i=0,j=0,x; while(sh[i]!=':') { ah[i]=sh[i]; i++; } ah[i]='\0'; x=i; i=x+3; while(sh[i]!='/') { bh[j]=sh[i]; i++;j++; } bh[j]='\0'; if(strcmp(ah,"http")==0){ cout<<ah<<endl; cout<<bh<<endl; } else { cout<<ah<<endl; cout<<bh<<endl; }cout<<endl; } return 0; }

转载请注明原文地址: https://www.6miu.com/read-63393.html

最新回复(0)