在此代码中,输出为“ r”而不是“ r0”
不是执行操作,而是向我输出第一个“ r”(等于100),并且不执行该过程。 我正在尝试对(x_0 = x +(nt²/(2(x +(n(t-1)²/ 2)(x +(n(t-3)²)/ 2(x +(n(t -4)²...)²)²)²)²)²)²)²)²),重复执行该过程直到变量't'为'0'(因为每次执行操作't '得到'-1')。
#include <iostream>
#include "math.h"
using namespace std;
int operation(float r,
float r0,
float recursiva,
float operacion,
float recursivaPrincipal2,
float recursivaPrincipal,
float p,
float n,
long long t,
float q,
float potenciaQ,
float c,
float potenciaC,
float t2,
float division);
float r = 100;
float t = 10000;
float r0;
float recursiva;
float operacion;
float recursivaPrincipal2;
float recursivaPrincipal;
float p;
float n;
float q;
float potenciaQ;
float c;
float potenciaC;
float t2;
float division;
int main() {
r0 = r + operacion;
potenciaQ = pow(10,10);
q = 6 * potenciaQ;
potenciaC = pow(10,2);
c = 5 * potenciaC;
while (t = 10000, t = t - 1, t > 0) {
t2 = t * t;
n = q * t2;
operacion = n / recursivaPrincipal;
recursivaPrincipal2 = recursiva * recursiva;
recursivaPrincipal = 2 * recursivaPrincipal2;
recursiva = r + operacion;
if (t == 0) {
system("pause");
return 0;
}
cout << "Solucion: " << r0 << endl;
}
}
i want to do something like this
如果这个代码冒犯了您,我很抱歉(评论看起来像这样),但是我不是很好,这是我的第一个c ++代码(也是我想的)
答案 0 :(得分:0)
答案基于我从您的问题中得到的答案
请为t = 3扩展数学表达式,并为其添加图片
到目前为止,我从你的表情中得到的是你需要的
float func(int t,int n,int x)
{
if (t==1)
{
return (x + (n/2)*(n/2)) * (x + (n/2)*(n/2));
}
return x + (n*t*t)/(2*func(t-1,n,x)) ;
}
根据您上传的图片,这是我的代码
对于n请勿使用0
#include<iostream>
using namespace std;
double partSolver(int x,int p, int n)
{
if(n==0) return 2*x*x;
double val = x - ( (p*n*n) / partSolver(x,p,n-1) );
return 2*val*val ;
}
double solver(int x,int p,int n)
{
return (n*n * 2) / partSolver(x,p,n-1);
}
int main()
{
cout<<"The Solution is: "<<solver(3,2,1)<<endl;
return 0;
}