代码是什么意思。请解释一下代码? [英] what is meant by the code. please explain the code?

查看:78
本文介绍了代码是什么意思。请解释一下代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< pre lang =   cs> public  class 活动{
私有 字符串 id;
private string description;
private int duration;
private int \\ test;
private int lst;
private int eet;
private int let ;
private 活动[]后继者;
私人活动[]前辈;
}
/// ////////////// //////////////////////////////////
private static 活动[] WalkListAback(活动[]列表)
{
list [na - 1 ]。令= list [na - 1 ] .Eet;
list [na - 1 ]。Lst = list [na - 1 ]。让 - list [na - 1 ]。持续时间;

for int i = na - 2 ; i& gt; = 0 ; i--)
{
foreach (活动活动 list [i] .Successors)
{
if (list [i] .Let == 0
list [i] .Let = activity.Lst;
else
if (list [i] .Let& gt; activity .Lst)
list [i] .Let = activity.Lst;
}

list [i] .Lst = list [i] .Let - list [i] .Duration;
}
return list;
}
< / pre >

解决方案

您是否知道逐行解释代码的工作量是多少?

每一行都需要一段解释!例如:

 int next = r.Next(); 



创建一个名为next的新变量,它可以包含一个整数值。从先前声明的Random实例r,调用Next方法获取一个新的随机数,并将其分配给next变量。



可以你想象我们需要多长时间才能解释一个像你的例子一样的非常短的代码片段,一行一行?



不会发生这种情况。如果您有特定问题,请询问有关它的问题。但首先想一想 - 你想坐下45分钟然后输入逐行描述没有充分理由吗?



所以不 - 回去无论你在哪里找到代码,并在那里问。


几乎不可能回答你的问题,因为你没有给我们上下文,没有样本数据。



唯一可行的方法是使用调试器来查看代码正在做什么。

调试器允许你一步一步地运行代码在代码运行时检查变量。



现在,你给我们的最好线索是函数名 WalkListAback

<pre lang="cs">public class Activity {
    private string id;
    private string description;
    private int duration;
    private int est;
    private int lst;
    private int eet;
    private int let;
    private Activity[] successors;
    private Activity[] predecessors;
}
///////////////////////////////////////////////////
private static Activity[] WalkListAback(Activity[] list)
    {
        list[na - 1].Let = list[na - 1].Eet;
        list[na - 1].Lst = list[na - 1].Let - list[na - 1].Duration;

        for(int i = na - 2; i &gt;= 0; i--)
        {
            foreach(Activity activity in list[i].Successors)
            {
              if(list[i].Let == 0)
                list[i].Let = activity.Lst;
              else
                if(list[i].Let &gt; activity.Lst)
                  list[i].Let = activity.Lst;
            }

            list[i].Lst = list[i].Let - list[i].Duration;
        }
        return list;
    }
</pre>

解决方案

Do you have any idea how much work explaining code line by line is?
Every single line needs a paragraph of explanation! For example:

int next = r.Next();


Create a new variable called "next" which can hold a integer value. From the previously declared Random instance "r", call the "Next" method to get a new random number, and assign it to the "next" variable.

Can you imagine how long it would take us to explain even a very short code fragment like your example, line by line?

No. It is not going to happen. If you have a specific problem, then ask a question about it. But think first - would you want to sit down for 45 minutes and type up a line-by-line description for no good reason?

So no - go back to wherever you found the code, and ask there.


It is almost impossible to answer your question because you didn't gave us the context, there is no sample data.

The only practical thing to do is to use a debugger to see what the code is doing.
The Debugger allow you to run the code step by step and inspect variables as the code is running.

For now, the best clue your gave us is the function name WalkListAback


这篇关于代码是什么意思。请解释一下代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆