日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

C - Internet Address CodeForces - 245B(有些思维的水题)

發(fā)布時(shí)間:2023/12/15 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 C - Internet Address CodeForces - 245B(有些思维的水题) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format:

?/.ru[/]
where:

can equal either “http” (without the quotes) or “ftp” (without the quotes),
is a non-empty string, consisting of lowercase English letters,
the / part may not be present. If it is present, then is a non-empty string, consisting of lowercase English letters.
If string isn’t present in the address, then the additional character “/” isn’t written. Thus, the address has either two characters “/” (the ones that go before the domain), or three (an extra one in front of the context).

When the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn’t write characters “:”, “/”, “.”.

Help Vasya to restore the possible address of the recorded Internet resource.

Input
The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only.

It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above.

Output
Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them.

Examples
Input
httpsunrux
Output
http://sun.ru/x
Input
ftphttprururu
Output
ftp://http.ru/ruru
Note
In the second sample there are two more possible answers: “ftp://httpruru.ru” and “ftp://httpru.ru/ru”.
這個(gè)題很好懂,注意一些細(xì)節(jié)就好了。有一些細(xì)節(jié)想不到。
代碼如下:

#include<iostream> #include<cstring> #include<cstdio> using namespace std;char s[52]; char ss[52]; int main() {while(scanf("%s",s)!=EOF){int flag=0;memset(ss,'\0',sizeof(ss));int len=strlen(s);int cnt=0;for(int i=0;i<len;){if(i==0){if(s[i]=='h'&&s[i+1]=='t'&&s[i+2]=='t'&&s[i+3]=='p'){printf("http://");i+=4;continue; //這里wa了一次,沒有加這個(gè)結(jié)果和應(yīng)該輸出的不一樣}if(s[i]=='f'&&s[i+1]=='t'&&s[i+2]=='p'){printf("ftp://");i+=3;continue;//一樣}}else{ss[cnt++]=s[i++];if(s[i]=='r'&&s[i+1]=='u'){ss[cnt]='\0';printf("%s.ru",ss);if((i+1)!=(len-1)) printf("/");//!!!!!httpcsdfvdru這樣的樣例應(yīng)該輸出htt://pcsdfvd.ru而不是htt://pcsdfvd.ru/i+=2;while(i<len)printf("%c",s[i++]);//上面的執(zhí)行完了以后就把原來的剩下的輸出就好了break;//退出}}}cout<<endl;} }

努力加油a啊,(o)/~

總結(jié)

以上是生活随笔為你收集整理的C - Internet Address CodeForces - 245B(有些思维的水题)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。