小编Mik*_*her的帖子

理解写得不好的代码,第二年CS过去的论文

问题是描述代码的作用,功能的作用.

以下代码是过去第二年C和C++模块考试试卷的一部分.任务是描述以下代码的作用.我完全按照提交的方式编写了代码,并自己添加了一些注释.

int g(int * y, unsigned size, int z) {
    int tmp = y[0];
    // what type is unsigned size? Int I presume. Why would you add an int to an array of ints?
    int * b = y + size; 
    y[0] = z;
    // I have the most difficulty understanding the following.
    while (1) if (*(--b)==z){y[0] = tmp; return b - y;};
    // are the following 3 lines ever even reached?
    y[0] = tmp;
    if (tmp == z) …
Run Code Online (Sandbox Code Playgroud)

c c++ algorithm coding-style

10
推荐指数
3
解决办法
691
查看次数

标签 统计

algorithm ×1

c ×1

c++ ×1

coding-style ×1