题解 | #邮箱验证#

邮箱验证

http://www.nowcoder.com/practice/8f908eeee4aa412ca88304f0acbaa1f9

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.next();
        int count1 = str.indexOf("@");
        int count2 = str.indexOf(".com");
        if(count1!=-1&&count2!=-1&&count1<count2&&count1!=0)
        {
            System.out.println("邮箱格式合法");
        }
        else{
            System.out.println("邮箱格式不合法");
        }
    }
}
全部评论
加油
点赞 回复 分享
发布于 2023-06-10 08:32 辽宁
感觉不是太严谨,邮箱字符长度没有考虑
点赞 回复 分享
发布于 2023-06-02 20:42 山东
加油~
点赞 回复 分享
发布于 2022-04-23 10:58

相关推荐

星辰再现:裁员给校招生腾地方
点赞 评论 收藏
分享
评论
3
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务