当前位置: 首页 > news >正文

沧州wap网站制作/大丰seo排名

沧州wap网站制作,大丰seo排名,网站充值支付宝收款怎么做,国家安全部副部长名单在实际的工作中,需要提取程序中的字符串信息,但是程序中经常将一些数字当做字符串来进行处理,例如表盘的刻度信息,这时候就需要判断字符串是否全为数字,来进行真正意义上的字符串提取。下面介绍了判断字符串是否全为数…

  在实际的工作中,需要提取程序中的字符串信息,但是程序中经常将一些数字当做字符串来进行处理,例如表盘的刻度信息,这时候就需要判断字符串是否全为数字,来进行真正意义上的字符串提取。下面介绍了判断字符串是否全为数字的方法,仅供参考。

  方法一:判断字符的ASCII范围(数字的范围为48~57)

  

 1 #include <iostream>
 2 using namespace std;  
 3 
 4 bool AllisNum(string str); 
 5  
 6 int main( void )  
 7 {  
 8 
 9     string str1 = "wolaiqiao23";  
10     string str2 = "1990";  
11 
12     if (AllisNum(str1))
13     {
14         cout<<"str1 is a num"<<endl;  
15     }
16     else
17     {
18         cout<<"str1 is not a num"<<endl;  
19     }
20 
21     if (AllisNum(str2))
22     {
23         cout<<"str2 is a num"<<endl;  
24     }
25     else
26     {
27         cout<<"str2 is not a num"<<endl;  
28     }
29 
30     cin.get();
31     return 0;  
32 }  
33  
34 bool AllisNum(string str)  
35 {  
36     for (int i = 0; i < str.size(); i++)
37     {
38         int tmp = (int)str[i];
39         if (tmp >= 48 && tmp <= 57)
40         {
41             continue;
42         }
43         else
44         {
45             return false;
46         }
47     } 
48     return true;
49 }  

  方法二:使用C++提供的stringstream对象 

 1 #include <iostream>
 2 #include <sstream>  
 3 using namespace std;  
 4 
 5 bool isNum(string str);  
 6 
 7 int main( void )  
 8 {
 9     string str1 = "wolaiqiao23r";  
10     string str2 = "1990";  
11     if(isNum(str1))  
12     {  
13         cout << "str1 is a num" << endl;  
14     }  
15     else
16     {  
17         cout << "str1 is not a num" << endl;  
18 
19     }  
20     if(isNum(str2))  
21     {  
22         cout<<"str2 is a num"<<endl;  
23     }  
24     else
25     {  
26         cout<<"str2 is not a num"<<endl;  
27 
28     }  
29 
30     cin.get();
31     return 0;  
32 }  
33 
34 bool isNum(string str)  
35 {  
36     stringstream sin(str);  
37     double d;  
38     char c;  
39     if(!(sin >> d))  
40     {
41         return false;
42     }
43     if (sin >> c) 
44     {
45         return false;
46     }  
47     return true;  
48 } 

  运行结果

  

 

转载于:https://www.cnblogs.com/MakeView660/p/6077371.html

http://www.jmfq.cn/news/4752361.html

相关文章:

  • it培训机构网站开发/网络推广业务
  • 自己做网赌网站/营销网站案例
  • 哪里有营销型网站制作/搜狗提交入口网址
  • 国内建站源码/网络营销试卷
  • 大宗商品交易平台软件排行/日照网站优化公司
  • 西宁网站开发多少钱/企业网站类型有哪些
  • 做租凭网站是经营性吗/上海谷歌推广
  • 微信小商店官网入口/济南seo整站优化价格
  • 南通优化网站公司/排行榜哪个网站最好
  • 国外专门做视频翻译网站/web成品网站源码免费
  • 免费做deal的网站/网页平台做个业务推广
  • 上海市建设工程安全协会网站/sem营销是什么意思
  • 江苏建设网/搜索引擎优化排名seo
  • 怎么切页面做网站/seo资源网站 排名
  • 郯城做网站/自己做seo网站推广
  • 高清视频服务器内存/成都网站seo公司
  • 做海报的参考网站/cps广告联盟网站
  • 中国做网站公司/免费发布活动的平台
  • 牟平网站制作/威海seo公司
  • wordpress仿58同城/seo 推广怎么做
  • 河南省内 在哪个网站做商检表/百度指数官网
  • 帮别人做网站的合作协议/seo检测优化
  • 微信小程序开发模板网站/整合营销传播案例分析
  • wordpress语言包下载地址/百度推广优化师
  • 做肮脏交义的网站/收录平台
  • 建筑网址导航/宁波seo外包服务
  • 大连建设网站公司/世界十大搜索引擎及地址
  • 武汉商业网站/搜索引擎技巧
  • 怎么做外语网站/seo研究中心论坛
  • wordpress目的/长沙快速排名优化