Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 什么';这个循环代码中有什么错误_C#_Loops_Curve_Do While - Fatal编程技术网

C# 什么';这个循环代码中有什么错误

C# 什么';这个循环代码中有什么错误,c#,loops,curve,do-while,C#,Loops,Curve,Do While,问题是: 常数:“a”、“b”、“c”、“d” 我有很多变量,但只有这些变量是相互关联的:“x”,“y”,“z” 对于第一次迭代1,您必须: x1 = [value from other variables]; y1 = x1 + a; z1 = y1 + x1 + b; condition |c - z1| < d; x1=[来自其他变量的值]; y1=x1+a; z1=y1+x1+b; 条件| c-z1 |

问题是:

常数:“a”、“b”、“c”、“d”

我有很多变量,但只有这些变量是相互关联的:“x”,“y”,“z”

对于第一次迭代1,您必须:

x1 = [value from other variables];
y1 = x1 + a;
z1 = y1 + x1 + b;
condition |c - z1| < d;
x1=[来自其他变量的值];
y1=x1+a;
z1=y1+x1+b;
条件| c-z1 |
如果为真,则程序计算其他元素(从这一点我知道作业),但如果条件为假,则我们有如下内容:

x2 = x1 + e;
y2 = x2 + a;
z2 = y2 + x2 + b;
condition |c - z2| < d; 
x2=x1+e;
y2=x2+a;
z2=y2+x2+b;
条件| c-z2 |
同样,如果为false:

x3 = x2 + e;
y3 = x3 + a;
z3 = y3 + x3 + b;
condition |c - z3| < d; 
x3=x2+e;
y3=x3+a;
z3=y3+x3+b;
条件| c-z3 |
等等,直到满足条件为止

我试图解决的是一个循环,从上一次迭代中提取“xi”和“yi”的值,以便在以后的开发中使用。除非条件满足,否则我无法提取它们

谢谢。

您可以使用:


var x=//来自其他变量的值
变量y=x+a;
var z=y+x+b;
while(Math.Abs(c-z)
谢谢,希望它能起作用。var x=//来自其他变量的值var y=x+a;var z=y+x+b;而(数学Abs(c-z)var x = // value from other variables var y = x + a; var z = y + x + b; while (Math.Abs(c - z) < d) { x = x + e; y = x + a; z = y + x + b; }