我坚持使用循环条件中未在循环体中修改的错误变量 'n' 和 'm'
I am stuck with that error variables 'n' and 'm' used in loop condition not modified in loop body
#include <cs50.h>
#include <stdio.h>
int main(void)
{
// TODO: Prompt for start size
int n,m,y,b,a;
do{
n= get_int("Start Size");
}
while(n <9);
// TODO: Prompt for end size
do
{
m = get_int("End Size");
}
while(n > m);
// TODO: Calculate number of years until we reach threshold
for (y=0;n>m;y++)
{
a = n/3;
b = n/4;
y= n + a-b;
}
// TODO: Print number of years
{
printf("Years:%i\n",y);
}
}
请问我为什么会出现这个错误(循环条件中使用的变量 'n' 和 'm' 未在循环体中修改)?
结束循环的条件不依赖于循环内发生的任何变化。所以循环要么永远不会执行,要么永远执行。
#include <cs50.h>
#include <stdio.h>
int main(void)
{
// TODO: Prompt for start size
int n,m,y,b,a;
do{
n= get_int("Start Size");
}
while(n <9);
// TODO: Prompt for end size
do
{
m = get_int("End Size");
}
while(n > m);
// TODO: Calculate number of years until we reach threshold
for (y=0;n>m;y++)
{
a = n/3;
b = n/4;
y= n + a-b;
}
// TODO: Print number of years
{
printf("Years:%i\n",y);
}
}
请问我为什么会出现这个错误(循环条件中使用的变量 'n' 和 'm' 未在循环体中修改)?
结束循环的条件不依赖于循环内发生的任何变化。所以循环要么永远不会执行,要么永远执行。