我如何编写for和使用math.tan来总结那些切线? [英] How i have to write the for and use math.tan to sum those tangents?

查看:62
本文介绍了我如何编写for和使用math.tan来总结那些切线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是练习:


tg(1 + tg(2 + tg(3 + .... + tg(99 + tg(100)))。 ..))


我尝试过任何不同的方式,但bcs我是新的,并且不明白如何正确使用我无法设法做到这一点。


这是我的一次尝试:


           双重结果; //弧度角度 

            double sum = 0;





< span style ="font-size:12px">  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(result = 1; result< = 100; result = result + 1)

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(结果%结果== 0)

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;总和+ =结果;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.WriteLine(" Tangent of" + result +" 是" + Math.Tan(result));

&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.WriteLine(sum);

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }


它可能不正确但如果你帮我解决它会很开心!提前致谢!


解决方案

问候蝾螈。


我不确定这项运动意味着什么。是否"tg"平均切线?


假设确实如此,那你就不是在找钱。您正在寻找切线正切的切线......等等100次。


我不愿意为你做这项运动,因为我们不应该做功课。但你确实有自己的想法。我自己并不是100%肯定答案。所以这次我会提出一点。


这就是我认为的答案。记住,我不确定,所以你必须确保自己。如果你按原样使用我的代码,结果证明是错的,不要怪我。

 static void Main( string [] args)
{
double result = 0.0;

for(int i = 100; i> 0; i--)
{
result = Math.Tan(result +(d​​ouble)i);
}

Console.WriteLine(" {0}",result);
}


所以,第一次循环,结果将为零,我将为100,因此结果将变为100的tan。下一次,结果将被设置为前一个结果的棕褐色加上99.下次将是前一个结果的棕褐色+
98,依此类推。 i的值继续下降,当循环达到零时循环停止(因此最后一次循环,它将为1)。


This is the exercise:

tg(1+tg(2+tg(3+....+tg(99+tg(100)))...))

I tried any different ways but bcs im new and dont understand exactly how to use for properly i cant manage to do this.

This is one of my attempts:

            Double result; // angle in radians 
            double sum = 0;


            for (result = 1; result <= 100; result = result + 1)
            {
                if (result % result == 0)
                {
                    sum += result;
                }
                Console.WriteLine("Tangent of " + result + "  is " + Math.Tan(result));
                Console.WriteLine(sum);
            }

Its probably not correct but will be very happy if you help me solve it! Thanks in advance!

解决方案

Greetings Salamander.

I'm not certain what the exercise means. Does "tg" mean tangent?

Assuming it does, you are not looking for a sum. You are looking for a tangent of a tangent of a tangent ... and so on 100 times.

I'm reluctant to do the exercise for you, because we are not supposed to do homework. But you did have a go yourself. And I am not 100% sure about the answer myself. So I will stretch a point this time.

Here is what I think the answer is. Remember, I am not certain, so you will have to make sure yourself. If you use my code as-is and it turns out to be wrong, don't blame me.

      static void Main(string[] args)
      {
         double result = 0.0;

         for (int i = 100; i > 0; i--)
         {
            result = Math.Tan(result + (double)i);
         }

         Console.WriteLine("{0}", result);
      }

So, the first time through the loop, result will be zero and i will be 100, so result will become the tan of 100. The next time through, result will be set to the tan of the previous result plus 99. The next time it will be the tan of the previous result + 98, and so on. The value of i keeps going down, and the loop stops when it gets to zero (so the last time through the loop, it will be 1).


这篇关于我如何编写for和使用math.tan来总结那些切线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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