Is it a Number? |
Time Limit: 1000ms, Special Time Limit:2500ms,Memory Limit:65366KB |
Problem description |
This is it! You've finally graduated and started working.Looking forward to some really cool tasks now. While you're skipping around in the eagerness of getting started, you're told what your first task is - Input Validation! You should check whether the typed input is an integer number.Time to get going! Given a sequence of characters, check whether they describe an integer number. Whitespace is allowed both before and after the number, but the rest of the input must consist of a single, non-negative integer number. Only digits will be accepted as the relevant part of the input (+ is not allowed, for instance). |
Input |
The first line of input contains a single number T, the number of test cases to follow. Then follow a single line for each test case; the input to be validated. |
Output |
For each test case, output a line containing the value of the number if the input is a valid integer number, or invalid input (all lowercase) if the input is not. |
Sample Input |
4 23 456 -36 0045 44.3 |
Sample Output |
invalid input invalid input 45 invalid input |
Judge Tips |
0 < T <= 500 Each test case will consist of at least 1 and at most 50 characters (excluding the line break). A test case can contain any character with an ASCII value between 32 and 126(inclusive). There should be no leading zeros in the output. |
Problem Source |
IDIOPEN 2011
题目大意:这道水题水的好郁闷啊,如果数字两旁有空格的格式是有效的~~呜呜 思路:切掉两边的空格然后当做正常的字符串来处理,特殊处理长度为一的字符 至于搞掉前导0,要注意用图像的思想啊,多画图,呗下标搞晕了~~~
program:
#include<iostream> |