[英]How to create a loop that won't stop until the condition is satisfied
我是C ++的新手,在学习C ++之前,我已经学习过pascal。 我必须一直重复输入过程,直到在pascal中满足此条件( 1 <= m <= n <= 1000000000, nm<=100000
)为止,使用“重复...直到”命令非常容易,但是在C ++中仅当条件为假时才停止的“ while”
如果您希望两个条件都为真,则只需将您的条件放入while循环中即可,用&&分隔每个条件:
尝试这个:
while(!(m>=1 && n>=1 && n<=1000000000 && (n-m) <=100000)){
// your code here
}
while(true){
if(m>=1 && n>=1 && n<=1000000000 && (n-m) <=100000)
break;
// do something
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.