urls.txt
来自「以前ACM在哈工程HRBEU做的一些简单题目」· 文本 代码 · 共 48 行
TXT
48 行
#include <iostream.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
char protocol[10],host[500],port[15],path[1000];
char s[2000],c;
long n,number;
int i,j,k=1;
cin>>n;
while(n--)
{
cin>>s;
i=0;
while(s[i]!=':')i++;
s[i]='\0';
strcpy(protocol,s);
strcpy(port,"<default>");
strcpy(path,"<default>");
i=i+3;
j=i;
while(s[i]!=':'&&s[i]!='/'&&s[i]!='\0')i++;
c=s[i];
s[i]='\0';
strcpy(host,s+j);
if(c==':')
{
number=atol(s+i+1);
sprintf(port,"%ld",number);
i++;
while(s[i]!='/'&&s[i]!='\0')i++;
c=s[i];
}
if(c=='/')
{
strcpy(path,s+i+1);
}
cout<<"URL #"<<k<<endl;
cout<<"Protocol = "<<protocol<<endl;
cout<<"Host = "<<host<<endl;
cout<<"Port = "<<port<<endl;
cout<<"Path = "<<path<<endl;
cout<<endl;
k++;
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?