zoukankan      html  css  js  c++  java
  • 判断是否为回文类型的字符串

     1 #include<iostream>
     2 using namespace std;
     3 
     4 bool Check_huiweng(const char* pstr, int n)
     5 {
     6     if (pstr == NULL)
     7         return false;
     8     char* front = const_cast<char*>(pstr);
     9     char* back = const_cast<char*>(pstr)+ n - 1;
    10 
    11     while (front < back)
    12     {
    13         if (*front != *back)
    14         {
    15             return false;
    16         }
    17         front++;
    18         back--;
    19     }
    20     return true;
    21 }
    22 
    23 void main()
    24 {
    25     char* str=(char*)malloc(sizeof(char));
    26     cout << "plz enter a string:" << endl;
    27     cin >> str;
    28     int N = strlen(str);
    29     bool result = Check_huiweng(str,N);
    30     
    31     system("pause");
    32 }
  • 相关阅读:
    23-10 条件查询
    22-9 聚合函数
    关系抽取snowball
    关系抽取bootstrap
    NER
    GPT
    因果卷积 空洞卷积
    XL-NET
    transoformer-XL
    transoformer
  • 原文地址:https://www.cnblogs.com/leejxyz/p/5534690.html
Copyright © 2011-2022 走看看