c++ 邮件完整性检测

Modified on: Thu, 14 Nov 2019 22:50:12 +0800 热度: 1,658 度
void TestEmailIntegrity()
{
    string eml;
    cin>>eml;
    
    int AtPos=(int)eml.find("@");
    int DotPos=(int)eml.find(".");
    int rDotPos=(int)eml.rfind(".");
    
    
    if(~AtPos && ~ DotPos && AtPos < DotPos)
    {
        if(AtPos>0 && rDotPos+1<eml.size() && eml.at(AtPos+1)!='.')
        cout<<"你的电子邮件为:"<<eml<<endl;
        else
            cout<<"无效的电子邮件"<<endl;
    }
    else
        cout<<"无效的电子邮件"<<endl;
}

添加新评论