while循环显示没有负数 [英] While loop that displays no negative numbers

查看:182
本文介绍了while循环显示没有负数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何写一个不显示负数的while循环???

How would i write a while loop that displays no negative numbers???

推荐答案


我怎么会写一个不显示负数的while循环???
How would i write a while loop that displays no negative numbers???



这很简单。如果exppresion为TRUE,你需要的只是简单的if-else语句在循环内不打印其他任何打印号码。


Savage

It''s quite simple.All that u need is simple if-else statment inside the loop if exppresion is TRUE don''t print anything else print that number.


Savage


好的就这样......



int n;

while(n = 0)

if(n> 0)

cin> ;> n;

else(n< 0)

cout<< "请输入另一个号码;



???? lol
ok so like this......



int n;
while (n = 0)
if (n>0)
cin >> n;
else (n < 0)
cout << " Please enter another number";


???? lol



ok就是这样......



ok so like this......



展开 | 选择 | Wrap | 行号


这篇关于while循环显示没有负数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆