退出与负整数while循环 [英] exiting a while loop with a negative integer
本文介绍了退出与负整数while循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要退出而()
当用户进入任意大小的负数。我需要什么样的条件在循环的开始,以获得循环当用户输入一个负数退出?
解决方案
INT I = -1;
做
{
I = magic_user_input();
//简单就够了吗?得到一个体面的编程书籍获得循环的窍门
}
而(ⅰ-1个)
编辑:对不起,我的错误:我'未正确申报:)现在应该没事使用
I want to exit a while()
when the user enters a negative number of any size. What kind of condition would I need at the start of the loop to get the loop to exit when the user enters a negative number?
解决方案
int i = -1;
do
{
i = magic_user_input();
//simple enough? get a decent programming book to get the hang of loops
}
while(i > -1)
edit: sorry, my mistake: 'i' wasn't declared properly :) now it should be fine to use
这篇关于退出与负整数while循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文