SLB二面

Q1

有一个文件有如下内容

using System.Reflection;

#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly: AssemblyConfiguration("Release")]
#endif

[assembly: AssemblyVersion("1.1")]
[assembly: AssemblyFileVersion("1.4.10.0")]
[assembly: AssemblyInformationalVersion("1.0.5.0")]

希望写一个C++函数,每次调用将该文件的AssemblyFileVersion和AssemblyInformationalVersion的倒数第二位加一。

void IncrementVersion(const std::string& filepath) {
    std::ifstream inFile(filepath);
    if (!inFile.is_open()) {
        std::cerr << "Failed to open the file." << std::endl;
        return;
    }

    std::ostringstream contents;
    std::string line;

    while (std::getline(inFile, line)) {
        if (line.find("AssemblyFileVersion") != std::string::npos || line.find("AssemblyInformationalVersion") != std::string::npos) {
            size_t lastDot = line.find_last_of('.');
            size_t secondLastDot = line.find_last_of('.', lastDot - 1);
            int number = std::stoi(line.substr(secondLastDot + 1, lastDot - secondLastDot - 1));
            number += 1;

            line = line.substr(0, secondLastDot + 1) + std::to_string(number) + line.substr(lastDot);
        }
        contents << line << "\n";
    }
    inFile.close();

    std::ofstream outFile(filepath, std::ios::trunc);
    if (!outFile.is_open()) {
        std::cerr << "Failed to open the file for writing." << std::endl;
        return;
    }
    outFile << contents.str();
    outFile.close();
}

或者用正则:

void IncrementVersionWithRegex(const std::string& filepath) {
    std::ifstream inFile(filepath);
    if (!inFile.is_open()) {
        std::cerr << "Failed to open the file." << std::endl;
        return;
    }

    std::ostringstream contents;
    std::string line;

    // Modified pattern to target the second to last number section of the version
    std::regex versionPattern(
	  R"delimiter((AssemblyFileVersion|AssemblyInformationalVersion)\("([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)"\))delimiter"
	);


    while (std::getline(inFile, line)) {
        std::smatch match;
        if (std::regex_search(line, match, versionPattern)) {
            int number = std::stoi(match[3].str());
            number += 1;

            // Construct the new version string
            std::string newVersion = match[1].str() + "(\"" + match[2].str() + "." + match[3].str() + "." + std::to_string(number) + "." + match[4].str() + "\")";
            
            line.replace(match.position(), match.length(), newVersion);
        }
        contents << line << "\n";
    }
    inFile.close();

    std::ofstream outFile(filepath, std::ios::trunc);
    if (!outFile.is_open()) {
        std::cerr << "Failed to open the file for writing." << std::endl;
        return;
    }
    outFile << contents.str();
    outFile.close();
}

int main() {
    IncrementVersionWithRegex("your_file_path_here.cs");
    return 0;
}

Q2

2. 两数相加

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
    int carryOn = 0;
public:
    ListNode* addTwoNumbers(ListNode *l1, ListNode *l2) {
        if (l1 == nullptr && l2 == nullptr && carryOn == 0) {
            return nullptr;
        }

        int n1 = l1 == nullptr ? 0 : l1->val;
        int n2 = l2 == nullptr ? 0 : l2->val;
        int val = n1 + n2 + carryOn;
        carryOn = val / 10;
        val = val % 10;
        ListNode *cur = new ListNode();
        cur->val = val;
        cur->next = addTwoNumbers(
            l1 == nullptr? nullptr : l1->next,
            l2 == nullptr? nullptr : l2->next
        );

        return cur;
    }
};

全部评论
请问你一面后多久收到的二面呀
点赞 回复 分享
发布于 2023-10-17 18:07 四川
大佬有终面具体时间通知吗
点赞 回复 分享
发布于 2023-10-19 16:28 陕西

相关推荐

hanliu:1. 排版与格式问题字体与对齐问题:标题和内容的字体大小差异不够明显,无法迅速吸引目光。某些文字看起来有些拥挤(比如校园经历中的“班委成员”部分)。2. 内容逻辑性模块顺序问题:实习经历放在较靠后的位置,实际上这部分内容对应聘来说更重要,建议提前突出。细节表述不够突出:比如教育背景部分的专业课程仅仅列出名字,没有说明自己在这些课程中表现如何或者掌握了什么技能,缺乏量化描述。多余内容:例如“班委成员”和“宣传委员”这类校园经历,叙述过于普通,缺乏和岗位相关的实质性贡献。,建议简写。3. 措辞专业性表达不够精准:例如“协助班长与团支书更好地为同学服务”显得较为笼统,没有实际成果的体现。用词重复:如“学习了焊接”“学习了光检”等重复词语较多,缺乏丰富的动词来展示个人能力(如“负责”“优化”“改进”等)。技能展示不足:虽然列出了UG和CAD证书,但没有明确提到这些技能如何在实际工作中发挥作用。4. 技能匹配度技能深度不足:虽然列出了掌握的软件和技术,但没有描述技能水平(如“熟练掌握”“精通”),也没有具体案例支持这些技能。缺乏岗位导向性:比如针对机械设计与制造方向,实习经历提到了“E6尾灯项目”,但没有详细说明自己在其中的技术贡献,可能会显得经验描述泛泛而谈。5. 自我评价问题表达空泛:如“具有良好的沟通协调能力”“责任心强”之类的描述太常见,没有让人眼前一亮的特点。缺乏成果支持:自我评价中的能力没有用具体项目、经历或成就来验证,可信度较弱。 兄弟加油
点赞 评论 收藏
分享
lingo12:1.最好加个业务项目,大部分面试官工作以后会更偏重业务 2.实习部分描述一般般,可能hr看到会觉得你产出不够不给你过简历 3.蓝桥杯这些大部分人都有的,不如不写,反而减分项。
点赞 评论 收藏
分享
评论
1
5
分享

创作者周榜

更多
牛客网
牛客企业服务