• cf B. Internet Address


    坑。http://codeforces.com/contest/245/problem/B

    B. Internet Address
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    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:

    <protocol>://<domain>.ru[/<context>]

    where:

    • <protocol> can equal either "http" (without the quotes) or "ftp" (without the quotes),
    • <domain>is a non-empty string, consisting of lowercase English letters,
    • the /<context> part may not be present. If it is present, then <context> is a non-empty string, consisting of lowercase English letters.

    If string <context> 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.

    Sample test(s)
    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".

    水题一枚:

    View Code
     1 #include<stdio.h>
     2 #include<string.h>
     3 int main()
     4 {
     5     char str[60];
     6     char ans1[5],ans2[60],ans3[60];
     7     while(~scanf("%s",str))
     8     {
     9         int i;
    10         if(str[0]=='f')
    11         {
    12             printf("ftp://");
    13             i=3;
    14         }
    15         else
    16         {
    17             printf("http://");
    18             i=4;
    19         }
    20         int flag=0,flag2=0;
    21         int len=strlen(str);
    22         printf("%c",str[i]);
    23                 /*
    24                 <domain> is a non-empty string
    25                 至少一个字符先输出 
    26                 这里害坑了我 
    27                 */ 
    28         for(int j=i+1;str[j]!='\0';j++)
    29         {
    30             
    31             if(flag==0&&str[j]=='r'&&str[j+1]=='u')
    32             {
    33                 printf(".ru");
    34                 /*
    35                 之前写成这样 
    36                 printf(".ru/");
    37                 错了,后面可能为空,空不需要"/"
    38                                 所以在后面判断 
    39                 */
    40                 j++;
    41                 flag=1;
    42                 if(flag2==0&&j!=len-1)
    43                 {
    44                     printf("/");
    45                     flag2=1;
    46                 }
    47             }
    48             else 
    49             printf("%c",str[j]);
    50             
    51         }
    52         printf("\n");
    53         
    54     }
    55 }
  • 相关阅读:
    IOI2021集训队作业 CK String Theory
    IOI2021集训队作业 123ED Gem Island
    IOI2021集训队作业 121MB Bipartite Blanket
    ASP.NET站点Web部署(一键发布的实现)
    HTTP文件上传
    前言
    关于 Mybatis的原生连接池 和 DBCP 连接池
    linux 学习 端口占用 && 内存使用
    跨域问题
    Cassandra 学习三 安装
  • 原文地址:https://www.cnblogs.com/1114250779boke/p/2778881.html
Copyright © 2020-2023  润新知