题目链接

题目描述
Please create a function to extract the filename extension from the given path,return the extracted filename extension or null if none.

#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int i;
    for(i=0;i<s.length();++i)
    {
        if(s[i]=='.') break;
    }
    if(i==s.length())
    {
        cout<<"null"<<endl;
    }else
    {
        for(i++;i<s.length();++i)
        {
            cout<<s[i];
        }
        cout<<endl;        
    }
    return 0;
}
Last modification:September 21st, 2019 at 12:38 am
如果觉得我的文章对你有用,请随意赞赏