| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 74468 | 林Qmay | 二分查找 | C++ | Compile Error | 0 | 0 MS | 0 KB | 984 | 2023-05-26 19:26:38 |
#include"iostream" #include<stdio.h> #include"string" #define MAX 100 using namespace std; /*这是错误的,传进str的整个string则没有办法化解成小问题,这里需要指 之后强行把string str 改为指针也不对,会出现异常错误。 int per(int n ,string str){ if (n == 1 && n == 0) return 1; else { per(n - 2, str[1]); } } */ int per(int n, char *str) { if (n == 1 || n == 0) return 1; else { if (str[0] == str[n - 1]) per(n - 2, &str[1]); else return -1; } } int main() { int len; char str[MAX]; while(1) { printf("please enter the word :"); //os<<s scanf("%s", &str); len = (int)strlen(str); int result = per(len, str); if (result == 1) printf("true\n"); else printf("fault\n"); } system("pause "); }