暑假集訓7 11 字串回文暴力

2022-05-04 20:39:09 字數 735 閱讀 6128

#include #include #include #include #include #include #include #include #include #include #include using namespace std;

typedef long long ll;

typedef unsigned long long ull;

#define mm(a,b) memset(a,b,sizeof(a));

const double eps = 1e-10;

const int inf =0x7f7f7f7f;

const double pi=acos(-1);

int p2,q2,p1,ep,q1;

const int inf = 0x3f3f3f3f;

const int maxn = 1100;

int l;

char s[200000+10],s1[200000+10];

bool check(int pos)

{ int m=0;

for(int i=0;i

分析:很好的一道題目啊,想到了要將字串取反放進乙個新的陣列中,最後卻處理的比較複雜,學習一下簡潔 的解法,首先找到使得整個字串不滿足回文的字元第一次出現的位置,那麼要讓陣列變成回文就必須處理一下這個 位置也就是刪除乙個,不過可以刪除前面的乙個,也可以刪除後面的乙個,究竟刪除哪乙個?其實也只有兩種情況 暴力求一下就好

練習7 11 字串逆序 15分

輸入乙個字串,對該字串進行逆序,輸出逆序後的字串。輸入在一行中給出乙個不超過80個字元長度的 以回車結束的非空字串。在一行中輸出逆序後的字串。hello world dlrow olleh1.直接寫 include include intmain 2.使用函式 include include voi...

寒假集訓作業(4) 字串

include include includeusing namespace std int main strcpy unsorted i 1 key a i 1 p int main for int i 0 i 9 i insertsort name,p for int i 0 i 9 i a i...

codeup5901 字串 回文串

讀入一串字元,判斷是否是回文串。回文串 是乙個正讀和反讀都一樣的字串,比如 level 或者 noon 等等就是回文串。一行字串,長度不超過255。如果是回文串,輸出 yes 否則輸出 no yes1.c語言中使用eof代表 1 2.gets 函式的返回值為字元陣列的首位址,能夠讀取空格,以回車作為...