filename

//------------------------------------filename---------------------------------//
/*
题目描述
Please create a function to extract the filename extension from the given path,return the extracted filename extension or null if none.
输入描述:
输入数据为一个文件路径
输出描述:
对于每个测试实例,要求输出对应的filename extension

示例1
输入
Abc/file.txt
输出
txt
*/
//只要遇到.就把后面输出就行了,注意.如果为最后一个字符的情况
int f5()
{
    string str;
    cin >> str;
    if (str.size() != 0)
    {
        auto ptr = find(str.cbegin(), str.cend(), '.');
        if (ptr != str.cend())
        {
            ++ptr;
            for (; ptr != str.cend(); ++ptr)
                cout << *ptr;
            cout << endl;
        }
        else
            cout << "null";
    }
    return 0;
}

 

posted @ 2017-11-01 19:17  CoderZSL  阅读(515)  评论(0编辑  收藏  举报