我该如何解决这两项任务? [英] How do I solve this two tasks?

查看:104
本文介绍了我该如何解决这两项任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须编写一个程序,在C ++中以两种不同的方式解决这两个系列,其中一个使用q; q =(anext / aprevious)so:1 / S = X + X5 /5 + ... + x4n + 1 / 4n + 1;对于n = 7; X = 0.8; 2 / S = 1 + 3X2 + 5X4 /2!+ ... + + 2n + 1 * X2n / n !;对于n = 6,x = 0.5;请帮助我们:/我知道我可以使用循环来解决它们,但是我不明白怎么做!



我尝试了什么:



我尝试解决这个问题就像我之前提到的那样使用循环但是我不明白我应该怎么做!

I have to write a program that solves this two series in a two different ways in C++ one of them is using q; q=(anext/aprevious) so : 1/ S=X+X5 /5+...+X4n+1/ 4n+1; for n =7; x=0.8; 2/ S=1+3X2 +5X4 /2!+...+ 2n+1*X2n /n!; for n=6, x=0.5; help me guys please :/ I know I can solve them using cycles however, I did not understand how!

What I have tried:

I tried solving this like I mentioned before using loops but I didn't understand how should I do it!

推荐答案

我认为你需要创建表单的循环:

I think you need to make loops of the form :
int endValue = 7;   // for the first one
double result = 0;
for( int n = 1; n < endValue; ++n )
{
   // compute the nth item in the series and add to the result
   result += series( n );  
}



我假设系列以n为1开始。



确定计算结果系列中的每个项都是n的函数,并将每个项添加到结果中。


I assume the series starts with n at 1.

Determine the calculation for each term in the series as a function of n and add each one to the result.


Quote:

我尝试解决这个问题就像我之前提到的那样使用循环,但我不明白我该怎么做!

I tried solving this like I mentioned before using loops but I didn't understand how should I do it!



拿一张纸和一支铅笔。并且手动解决问题。

找到重复或重复的部分,如小的变化(如n = 1,2,3 ...)

重复的部分循环是什么。



我们不做你的HomeWork。

HomeWork没有设置测试你的技能,它设置为让您思考并帮助您的老师检查您对所学课程的理解以及您应用这些课程时遇到的问题。

你的任何失败都会帮助你的老师发现你的弱点并设定补救措施。

你的任何失败都会帮助你了解什么有效,什么无效,被称为'试错'学习。



作为程序员,你的工作是创建算法来解决具体问题。创建算法基本上是找到数学并进行必要的调整以适应您的实际问题。


Take a sheet of paper and a pencil. And solve the problem by hand.
Spot the parts that repeat or repeat with a small change (like n=1, 2, 3 ...)
That repeating part is what goes in loop.

We do not do your HomeWork.
HomeWork is not set to test your skills, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.

As programmer, your job is to create algorithms that solve specific problems. Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.


这篇关于我该如何解决这两项任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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