c++ 判断输入是否是字母的函数

[复制链接]
查看11 | 回复2 | 2010-4-24 17:06:11 | 显示全部楼层 |阅读模式
#include #include using namespace std;int main(){ char s[] = "pprf4.4hjudj7.8"; string str = s; char nums[] = "0123456789."; int begin = 0, end = 0; while(end != string.npos) {begin = str.find_first_of(nums, end);if(begin != string.npos){ end = str.find_first_not_of(nums, begin + 1); cout int main(void){ double a,b; sscanf("pprf4.4hjudj7.8","%*[^0-9]%lf%*[^0-9]%lf",&a,&b); printf("%g\n%g\n",a,b); return 0;}//---------------------------------------------------------------------------
回复

使用道具 举报

千问 | 2010-4-24 17:06:11 | 显示全部楼层
#include #include using namespace std;int main(){ char s[] = "pprf4.4hjudj7.8"; string str = s; char nums[] = "0123456789."; int begin = 0, end = 0; while(end != string.npos) {begin = str.find_first_of(nums, end);if(begin != string.npos){ end = str.find_first_not_of(nums, begin + 1); cout << string(str, begin, end - begin) << endl;}else break; } return 0;}
回复

使用道具 举报

千问 | 2010-4-24 17:06:11 | 显示全部楼层
ctype.hint isalpha( int c );isalpha returns a non-zero value if c is within the ranges A – Z or a – z.ASCII
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行