资讯   |   开发   |   选机中心   |   产品大全 | IBM | 惠普 | 联想 | 戴尔 | 苹果 | 神舟
更多: | 华硕 | 明基 | 方正 | 紫光 | TCL | 夏新 | 联宝 | 宏碁 | 七喜 | 长城 | 清华同方 | 海尔 | 三星 | 东芝 | 索尼 | 富士通 | LG | 技术 | ddnoon
当前位置:笔记本 > 软件开发 >
Advertisement
文章正文

请给一个原代码,可以学习到在书上学不到的东西,马上结帖

类型:转载   责任编辑:asp.net   日期:2007/05/23


热门软件下载:


   

请给一个原代码,可以学习到在书上学不到的东西,最好是有注释的,不要叫我去搜索了,那里找到的好象都不符号我的环境,不是太难就是没有注释,看起来很头痛的,  
   
  那位大哥可以给我发一个吗?或者是给我地址,谢谢  
   
  yjhyn@163.com

网友回答:

发表者:newegg2002

在书上学不到的东西?  
  楼主..怕没有什么东西是在书上学不到的吧...  
  你应该对"书上"作一下限定.:)  
   
  实际操作的经验是书上没有的...  
   
  楼主意思不明白...

发表者:diaoni

楼主的问题莫名其妙...  
  有详细注释的源代码,书上一大堆。

发表者:darkstar21cn

楼主指的是什么书?  
  如果没有特指的话,我想这个问题就没有答案了

发表者:apogeecsj

我学得C++都是书上看的...  
  int   main()  
  {  
  cout   <<   __FILE__   <<   endl;  
  return   main();  
  }

发表者:daylove

我考,这还不简单,  
   
  发了,你看看吧,不知道是否你需要!

发表者:greenteanet

Return   Value  
  The   index   of   the   first   character   of   the   substring   searched   for   when   successful;   otherwise   npos.  
   
  Example  
  //   basic_string_find.cpp  
  //   compile   with:   /EHsc  
  #include   <string>  
  #include   <iostream>  
   
  int   main(   )    
  {  
        using   namespace   std;  
   
        //   The   first   member   function  
        //   searches   for   a   single   character   in   a   string  
        string   str1   (   "Hello   Everyone"   );  
        cout   <<   "The   original   string   str1   is:   "   <<   str1   <<   endl;  
        basic_string   <char>::size_type   indexCh1a,   indexCh1b;  
        static   const   basic_string   <char>::size_type   npos   =   -1;  
   
        indexCh1a   =   str1.find   (   "e"   ,   3   );  
        if   (indexCh1a   !=   npos   )  
              cout   <<   "The   index   of   the   1st   e   found   after   the   3rd"  
                        <<   "   position   in   str1   is:   "   <<   indexCh1a   <<   endl;  
        else  
              cout   <<   "The   character   e   was   not   found   in   str1   ."   <<   endl;  
   
        indexCh1b   =   str1.find   (   "x"   );  
        if   (indexCh1b   !=   npos   )  
              cout   <<   "The   index   of   the   x   found   in   str1   is:   "    
                        <<   indexCh1b   <<   endl   <<   endl;  
        else  
              cout   <<   "The   Character   x   was   not   found   in   str1."  
                        <<   endl   <<   endl;  
   
        //   The   second   member   function   searches   a   string  
        //   for   a   substring   as   specified   by   a   C-string  
        string   str2   (   "Let   me   make   this   perfectly   clear."   );  
        cout   <<   "The   original   string   str2   is:   "   <<   str2   <<   endl;  
        basic_string   <char>::size_type   indexCh2a,   indexCh2b;  
   
        const   char   *cstr2   =   "perfect";  
        indexCh2a   =   str2.find   (   cstr2   ,   5   );  
        if   (   indexCh2a   !=   npos   )  
              cout   <<   "The   index   of   the   1st   element   of   perfect   "  
                        <<   "after\n   the   5th   position   in   str2   is:   "    
                        <<   indexCh2a   <<   endl;  
        else  
              cout   <<   "The   substring   perfect   was   not   found   in   str2   ."  
                        <<   endl;  
   
        const   char   *cstr2b   =   "imperfectly";  
        indexCh2b   =   str2.find   (   cstr2b   ,   0   );  
        if   (indexCh2b   !=   npos   )  
              cout   <<   "The   index   of   the   1st   element   of   imperfect   "  
                        <<   "after\n   the   5th   position   in   str3   is:   "  
                        <<   indexCh2b   <<   endl;  
        else  
              cout   <<   "The   substring   imperfect   was   not   found   in   str2   ."    
                        <<   endl   <<   endl;  
   
        //   The   third   member   function   searches   a   string  
        //   for   a   substring   as   specified   by   a   C-string  
        string   str3   (   "This   is   a   sample   string   for   this   program"   );  
        cout   <<   "The   original   string   str3   is:   "   <<   str3   <<   endl;  
        basic_string   <char>::size_type   indexCh3a,   indexCh3b;  
   
        const   char   *cstr3a   =   "sample";  
        indexCh3a   =   str3.find   (   cstr3a   );  
        if   (   indexCh3a   !=   npos   )  
              cout   <<   "The   index   of   the   1st   element   of   sample   "  
                        <<   "in   str3   is:   "   <<   indexCh3a   <<   endl;  
        else  
              cout   <<   "The   substring   perfect   was   not   found   in   str3   ."  
                        <<   endl;  
   
        const   char   *cstr3b   =   "for";  
        indexCh3b   =   str3.find   (   cstr3b   ,   indexCh3a   +   1   ,   2   );  
        if   (indexCh3b   !=   npos   )  
              cout   <<   "The   index   of   the   next   occurrence   of   for   is   in   "  
                        <<   "str3   begins   at:   "   <<   indexCh3b   <<   endl   <<   endl;  
        else  
              cout   <<   "There   is   no   next   occurrence   of   for   in   str3   ."    
                        <<   endl   <<   endl;  
   
        //   The   fourth   member   function   searches   a   string  
        //   for   a   substring   as   specified   by   a   string  
        string   str4   (   "clearly   this   perfectly   unclear."   );  
        cout   <<   "The   original   string   str4   is:   "   <<   str4   <<   endl;  
        basic_string   <char>::size_type   indexCh4a,   indexCh4b;  
   
        string   str4a   (   "clear"   );  
        indexCh4a   =   str4.find   (   str4a   ,   5   );  
        if   (   indexCh4a   !=   npos   )  
              cout   <<   "The   index   of   the   1st   element   of   clear   "  
                        <<   "after\n   the   5th   position   in   str4   is:   "    
                        <<   indexCh4a   <<   endl;  
        else  
              cout   <<   "The   substring   clear   was   not   found   in   str4   ."  
                        <<   endl;  
   
        string   str4b   (   "clear"   );  
        indexCh4b   =   str4.find   (   str4b   );  
        if   (indexCh4b   !=   npos   )  
              cout   <<   "The   index   of   the   1st   element   of   clear   "  
                        <<   "in   str4   is:   "  
                        <<   indexCh4b   <<   endl;  
        else  
              cout   <<   "The   substring   clear   was   not   found   in   str4   ."    
                        <<   endl   <<   endl;  
  }  
  Output  
  The   original   string   str1   is:   Hello   Everyone  
  The   index   of   the   1st   e   found   after   the   3rd   position   in   str1   is:   8  
  The   Character   x   was   not   found   in   str1.  
   
  The   original   string   str2   is:   Let   me   make   this   perfectly   clear.  
  The   index   of   the   1st   element   of   perfect   after  
    the   5th   position   in   str2   is:   17  
  The   substring   imperfect   was   not   found   in   str2   .  
   
  The   original   string   str3   is:   This   is   a   sample   string   for   this   program  
  The   index   of   the   1st   element   of   sample   in   str3   is:   10  
  The   index   of   the   next   occurrence   of   for   is   in   str3   begins   at:   24  
   
  The   original   string   str4   is:   clearly   this   perfectly   unclear.  
  The   index   of   the   1st   element   of   clear   after  
    the   5th   position   in   str4   is:   25  
  The   index   of   the   1st   element   of   clear   in   str4   is:   0  
  你看看这个程序吧

发表者:Mi_Bo

int   main()  
  {  
  cout   <<   __FILE__   <<   endl;  
  return   main();  
  }  
  这个其实是函数递归的

发表者:pacman2000

书上学不到?   不大可能吧。


 

 
热门推荐笔记本: 惠普笔记本
相关文章:
webmaster:popbb@126.com   最佳浏览:1024X768 MSIE
©2007 popbb.net All Rights Reserved