#include <iostream>
#include <string>
#include <fstream>
using namespace std;
void main
( )
{
const string BreakLine =
"<br />";
const string BlankLine =
"<p></p>";
string FileLine;
string modedString;
string httpString;
string modURL;
int len;
int pos;
int Blpos;
cout <<
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" << endl;
cout <<
"\"http://www.w3.org/TR/xhtmll/DTD/xhtmll-transitional.dtd\">" << endl;
cout <<
"<html xmlns=\"http:/\/www.w3.org/1999/xhtml\">" << endl <<
"<head>" << endl;
cout <<
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />" << endl;
cout <<
"<title>Untitled Document</title>" << endl;
cout <<
"</head>" << endl <<
"<body>" << endl;
getline
( cin, FileLine
);
while ( !cin.
eof( )) {
if (FileLine.
empty( ) ) {
cout << BlankLine << endl;
}
else if ((FileLine.
find("http")!=
string::
npos) ||
(FileLine.
find("Http") !=
string::
npos)) {
modedString = FileLine;
pos = modedString.
find("http");
while ( pos !=
string::
npos ) {
len = modedString.
length( );
httpString = modedString.
substr(pos, len
);
Blpos = httpString.
find(" ");
if (Blpos !=
string::
npos) {
len = httpString.
length( );
modUrl = httpString.
substr(0, Blpos
);
modedString.
erase(pos
);
cout << modedString <<
" <a href=\"" << modUrl <<
"\">";
cout << modUrl <<
"</a>";
modedString = httpString.
substr( Blpos, len
);
pos = modedString.
find("http");
}//end if
else if ( Blpos =
string::
npos ) {
modUrl = httpString.
substr(0, len
);
modedString.
erase(pos
);
cout << modedString <<
" <a href=\"" << modUrl <<
"\">";
cout << modUrl <<
"</a>";
modedString=
"";
pos = modedString.
find("http");
}//end else
}//end while
cout << modedString << BreakLine << endl;
}//end else
else {
FileLine = FileLine + BreakLine;
cout << FileLine << endl;
}//end else
getline
( cin, FileLine
);
}//end while
cout <<
"</body>" << endl <<
"<html>" << endl;
}