C++字符串反转
2021-06-12 07:02
                         标签:ever   turn   for   nbsp   自己   --   algo   main   begin     c++ 字符串反转的3种方法   1、使用string.h中的strrev函数   #include    #include    using namespace std;      int main()   {     char s[] = "hello";          strrev(s);     cout
     return 0;   }     2、使用algorithm中的reverse函数   #include    #include    #include    using namespace std;      int main()     {      string s = "hello" ;     reverse(s.begin(), s.end());     cout 
     return 0;   }     3、自己编写     #include    using namespace std;   void Reverse(char *s,int n)   {     for(int i = 0,j = n-1;i     {       char c = s[i];       s[i] = s[j];       s[j] = c;     }   }   int main()   {     char s[] = "hello";     Reverse(s,5);     cout
     return 0;   }   C++字符串反转 标签:ever   turn   for   nbsp   自己   --   algo   main   begin    原文地址:https://www.cnblogs.com/wjq13752525588/p/13512625.html
上一篇:C#定时器