判断一个字符是不是数字,也就是从字符串中提取字符串
通过isdigit()函数来运算:
其功能的实现见代码:
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <list>
#include <string.h>
#include <cstring>
#include <string>
#include <math.h>
using namespace std;
string str;
int main () {
while (cin >> str) {
int len = str.size();
for (int i = 0; i < len; i ++) {
if(isdigit(str[i]))
cout << str[i] << " " << endl;
}
}
return 0;
}