Detect Integer or Float
PHP
Easy
5 views
Problem Description
A number is given as text. Print INT if it looks like an integer, otherwise FLOAT.
Input Format
One token s.
Output Format
INT or FLOAT.
Official Solution
<?php
$inputText=trim(stream_get_contents(STDIN));
if($inputText==='') exit;
if(preg_match('/[\\.eE]/',$inputText)) echo 'FLOAT'; else echo 'INT';
?>
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!