//水
#include <iostream>
#include <string>
using namespace std;
int main()
{
int cases;
string str1, protocol, port, address, dictionary;
cin >> cases;
for (int t = 0; t != cases; ++t)
{
cin >> str1;
protocol = address = "";
port = dictionary = "<default>";
int pos = str1.find("://");
protocol = str1.substr(0, pos);
str1 = str1.substr(pos + 3);
pos = str1.find(":");
int pos2 = str1.find("/");
if (pos > 0 && (pos2 > pos || pos2 == -1))
{
address = str1.substr(0, pos);
if (pos2 > 0)
{
port = str1.substr(pos + 1, pos2 - pos - 1);
dictionary = str1.substr(pos2 + 1);
}
else
port = str1.substr(pos + 1);
}
else
{
if (pos2 > 0)
{
dictionary = str1.substr(pos2 + 1);
address = str1.substr(0, pos2);
}
else
address = str1;
}
cout << "URL #" << t + 1 << endl;
cout << "Protocol = " << protocol << endl;
cout << "Host = " << address << endl;
cout << "Port = " << port << endl;
cout << "Path = " << dictionary << endl << endl;
}
return 0;
}
zoj 1243
最新推荐文章于 2017-05-04 10:39:09 发布