1 条题解

  • 0
    @ 2025-4-12 21:36:07

    C :

    #include<stdio.h>
    #include<string.h>
    int main()
    {
        int i,d;
        char str[10000];
        while(scanf("%s",str)!=EOF)
        {
            d=0;       
            for(i=0;str[i]!='\0';i++)
            {
                if(!d)
                {
                  if(str[i]=='/'&&str[i-1]=='/')
                      d=1;
                }
                else 
                {if(str[i]==':'||str[i]=='/')
                            break;
                    printf("%c",str[i]);
                }
            }
            printf("\n");
        }
    return 0;
    }
    
    
      
    

    C++ :

    #include<iostream>
    #include<string>
    using namespace std;
    int main()
    {
        string str;
        while(cin>>str)
        {
            int pos1=str.find("//");
            int pos2=str.find(':',pos1+2);
            if(pos2==string::npos)
                pos2=str.find('/',pos1+2);
            cout<<str.substr(pos1+2,pos2-pos1-2)<<endl;
        }
        return 0;
    }
    
    
    • 1

    信息

    ID
    946
    时间
    1000ms
    内存
    32MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者