1 条题解

  • 0
    @ 2026-1-30 9:48:49
    #include<bits/stdc++.h>
    using namespace std;
    
    int main() {
        string s;
        cin >> s; // [1] 定义存储邮箱地址的字符串,并读取输入的邮箱
        int n = s.size(); // [2] 获取邮箱字符串的总长度
    
        // [3] 遍历邮箱字符串的每个字符,提取@前的用户名
        for(int i = 0; i < n; i++){
            if(s[i] == '@') break; // [4] 遇到@符号时,停止遍历(结束用户名提取)
            cout << s[i]; // [5] 输出当前字符,即用户名的一部分
        } 
        return 0;                  
    }
    
    • 1

    信息

    ID
    108
    时间
    1000ms
    内存
    256MiB
    难度
    1
    标签
    递交数
    1
    已通过
    1
    上传者