我们如何解释此代码 [英] how we can interpret this code

查看:57
本文介绍了我们如何解释此代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int diff = Math.Abs(startFreq - endFreq);
      diff = Convert.ToInt32(diff/duration);

      for (int rep=0; rep<reps; rep++)
      {
          // tone
          int CurrentFreq = startFreq;

          for(int i=0; i<steps-1; i++)
          {
              Beep(CurrentFreq, Convert.ToInt32(duration/steps));
              CurrentFreq = CurrentFreq + diff;
          }

          // dwell
          Thread.Sleep(dwell);
      }

推荐答案

这是一个简单的循环.如果您无法解释这里发生的情况,则应该实际去学习一些C#.比起尝试让人们告诉您所遇到的每个小问题的答案,这将更快,更有效.
This is a simple loop. If you can''t interpret what is going on here, you should actually go and learn some C#. It will be quicker and more effective than trying to get people to tell you the answer to every little problem you have.


您将从startFreq和(大概)以endFreq结尾(从代码中不确定,因为我不知道步数在哪里计算.).
实际上,似乎在第二行中将步骤和持续时间混为一谈,而且我不确定在Beep参数中为什么将持续时间除以步骤.
You are producing a series of beeps at different frequencies starting at startFreq and (presumably) ending at endFreq (it''s not certain from the code because I don''t know where steps is calculated).
It actually looks like steps and duration might be mixed up in the second line, and I''m not sure why duration is divided by steps in the Beep arguments.


这篇关于我们如何解释此代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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