zp1243_w.cpp

来自「浙江大学acm在线判题器代码集。 本人在浙大acm判题器上的所有代码(心血) 」· C++ 代码 · 共 52 行

CPP
52
字号
//---------------------------------------------------------------------------

#pragma hdrstop

//---------------------------------------------------------------------------

#pragma argsused
#define cin fin
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
  ifstream fin("d:\in1243.txt");
  int n,I,i,k,p,h,l;
  string st;
  cin>>n;
  for (I=1;I<=n;I++)
  {
    cin>>st;
    l=st.length();
    st[l]='!';
    i=0;
    while (st[++i]!=':') {}
    p=i;
    i+=2;
    while (st[++i]!='/' && st[i]!='!') {}
    h=i;
    i=p+3;
    while (st[++i]!=':' && st[i]!='!') {}
    k=i;if (st[i]=='!') k=h;
    cout<<"URL #"<<I<<endl<<"Protocol = ";
    for (i=0;i<p;i++)
      cout<<st[i];
    cout<<endl<<"Host     = ";
    for (i=p+3;i<k;i++)
      cout<<st[i];
    cout<<endl<<"Port     = ";
    if (st[k+1]=='!' || k==h) cout<<"<default>";
    else for (i=k+1;i<h;i++)
      cout<<st[i];
    cout<<endl<<"Path     = ";
    if (st[h]=='!') cout<<"<default>";
    else for (i=h+1;i<l;i++)
      cout<<st[i];
    cout<<endl<<endl;
  }
  return 0;
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?