编写函数,判断指定的字符是否是数字字符,如果是函数返回1,否则函数返回0.要求在主调函数中输入该字符,调用函数并输出判断结果。
输入格式:
在一行中给出1个字符。
输出格式:
对于给定输入的字符,输出判断结果yes或no。
输入样例: 6
输出样例: yes
输入样例: H
输出样例: no
代码实现(C++)
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
void f(char str)
{
if(str>='0'&&str<='9')
cout << "yes";
else
cout << "no";
}
int main()
{
char str;
cin >> str;
f(str);
return 0;
}