C++输入“1+23-456”输出数字个数
要求不使用库函数,定义函数解答
#include <iostream>
#include <string>
using namespace std;
void outNum(const char *str)
{
while(*str)
{
if(*str >= '0' && *str <= '9')
cout<<*str;
str++;
}
cout<<endl;
}
int main()
{
string str;
cin >> str;
outNum(str.c_str());
return 0;
}