检查输入是否为整数 [英] check if the input is integer

查看:82
本文介绍了检查输入是否为整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在编写一个应用程序来检查输入是否为整数,如果是整数则只打印整数值。我根本不知道请任何人帮助我。


谢谢

Sang

Hi

I am writing a application program that checks if the input is integer, if it is integer print the integer value only. i have no idea about that please any one help me.

Thanks
Sang

推荐答案





我正在编写一个应用程序来检查输入是否为整数,如果是整数则只打印整数值。我不知道请任何人帮助我。


谢谢

Sang
Hi

I am writing a application program that checks if the input is integer, if it is integer print the integer value only. i have no idea about that please any one help me.

Thanks
Sang



使用异常处理

,如

Use Exception handling
as in

展开 | 选择 | Wrap | 行号


感谢您的回复。


如果输入是整数,则打印此编码,否则不打印。我试图只获得整数值,我无法通过使用isNumber()来做到这一点,但我得到了错误。


所以,请给我代码为


如果输入是这样的1棵树中有3个苹果输出只有1& 3


只打印整数。


谢谢

Sang
Thanks for your reply.

This coding is print if the input is integer otherwise not printed. I am trying to get only integer values i am not able to do this by using the isNumber() but i am got the error.

so,please give me the code for

if the input is like this "There is 3 apples in 1 tree" the output is only 1 & 3

that is only print the integer.

Thanks
Sang


如果要在字符串中搜索数字,然后打印数字,您甚至不需要将其转换为整数。如果您使用底片,请务必修改if语句以接受减号和数字。
If you are going to search for a number within a string, then print the number, you don''t even need to convert it to an integer. If you are using negatives, be sure to modify the if statement to accept minus sign as well as digit.
展开 | 选择 | Wrap | 行号


这篇关于检查输入是否为整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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