245B. Internet Address

Problem Link

Solution

#include<bits/stdc++.h>
using namespace std;
vector<char>c;
int main()
{
string s;
cin>>s;
int i=0;
if(s[0]=='h')
{
for(int j=0;j<4;j++)
c.push_back(s[j]);
c.push_back(':');
c.push_back('/');
c.push_back('/');

i+=4;

}
else if(s[0]=='f')
{
for(int j=0;j<3;j++)
c.push_back(s[j]);
c.push_back(':');
c.push_back('/');
c.push_back('/');

i+=3;

}
if(s[i]=='r' &&s[i+1]=='u'){
    c.push_back(s[i]);
    c.push_back(s[i+1]);
    i+=2;
    }
int flag=0;

for(int j=i;j<s.size();j++)
{if(s[j]=='r' &&s[j+1]=='u' &&flag==0)
{   c.push_back('.');
    c.push_back(s[j]);
    c.push_back(s[j+1]);
    if(j+1!=s.size()-1)
    c.push_back('/');

   flag=1;j+=1;
}
else
c.push_back(s[j]);
}


for(int i=0;i<c.size();i++)
{
cout<<c[i];
}
}
Advertisements

About waprogramming

I am in CSE,from CUET
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s