substr not found
时间: 2023-12-23 13:02:14 浏览: 32
根据你提供的引用内容,你遇到了两个不同的问题。我将分别回答它们。
1. 在你的第一个引用中,你提到了在文件中加入"command not found"的应用bin目录,特别是将mysql的bin目录放在这里。你遇到了mysqld、mysqldump和mysqladmin命令无法使用的问题。这可能是因为这些命令的路径没有被正确地添加到系统的环境变量中。你可以尝试将mysql的bin目录添加到系统的环境变量中,以便系统可以找到这些命令。具体的步骤可能因操作系统而异,你可以参考操作系统的文档或搜索相关的教程来了解如何添加环境变量。
2. 在你的第二个引用中,你提到了在文件中使用new PHPExcel()类时报错"not found",但实际上这个类是存在的。你已经确认了项目中存在composer.json和composer.lock这两个文件。根据你的描述,这个问题可能是由于自动加载类的问题导致的。你的解决办法是使用require_once引入PHPExcel.php文件来解决这个问题。这种方法可以手动引入所需的类文件,但并不是最佳的解决方案。你可以尝试使用Composer来管理项目的依赖关系,并确保正确配置了自动加载类的机制。具体的步骤可以参考Composer的文档或搜索相关的教程。
相关问题
C语言编程:【样例输入】 abcdef def aaa 【样例输出】 please input 3 strings as MainStr , SubStr1 and SubStr2 MainStr =:6,a,b,c,d,e,f, SubStr1 =:3,d,e,f, SubStr2 =:3,a,a,a, SubStr1 compare with SubStr2 is 1 pos of SubStr1 in MainStr is 4 pos of SubStr2 in MainStr
这是一个字符串匹配的问题,需要编写 C 语言程序。下面是代码示例:
```c
#include <stdio.h>
#include <string.h>
int main() {
char MainStr[100], SubStr1[100], SubStr2[100];
int i, j, len1, len2, len3, pos1 = -1, pos2 = -1, flag = 0;
printf("please input 3 strings as MainStr , SubStr1 and SubStr2\n");
scanf("%s%s%s", MainStr, SubStr1, SubStr2);
len1 = strlen(MainStr);
len2 = strlen(SubStr1);
len3 = strlen(SubStr2);
printf("MainStr =:%d,", len1);
for (i = 0; i < len1; i++) {
printf("%c,", MainStr[i]);
}
printf(" SubStr1 =:%d,", len2);
for (i = 0; i < len2; i++) {
printf("%c,", SubStr1[i]);
}
printf(" SubStr2 =:%d,", len3);
for (i = 0; i < len3; i++) {
printf("%c,", SubStr2[i]);
}
printf("\n");
for (i = 0; i <= len1 - len2; i++) {
flag = 1;
for (j = 0; j < len2; j++) {
if (MainStr[i+j] != SubStr1[j]) {
flag = 0;
break;
}
}
if (flag == 1) {
pos1 = i + 1;
break;
}
}
flag = 0;
for (i = 0; i <= len1 - len3; i++) {
flag = 1;
for (j = 0; j < len3; j++) {
if (MainStr[i+j] != SubStr2[j]) {
flag = 0;
break;
}
}
if (flag == 1) {
pos2 = i + 1;
break;
}
}
if (strcmp(SubStr1, SubStr2) == 0) {
printf("SubStr1 compare with SubStr2 is 1\n");
} else {
printf("SubStr1 compare with SubStr2 is 0\n");
}
if (pos1 != -1) {
printf("pos of SubStr1 in MainStr is %d\n", pos1);
} else {
printf("SubStr1 not found in MainStr\n");
}
if (pos2 != -1) {
printf("pos of SubStr2 in MainStr is %d\n", pos2);
} else {
printf("SubStr2 not found in MainStr\n");
}
return 0;
}
```
程序实现了对三个字符串的输入,输出三个字符串的长度和内容。然后分别在 MainStr 中查找 SubStr1 和 SubStr2,输出它们在 MainStr 中的位置或者未找到的提示。最后比较 SubStr1 和 SubStr2 是否相同,输出比较结果。
已知一任意长度字符串str,以00h结束,长度小于200h,编写汇编程序实现在该字符串中搜索匹配子串substr(以00h结束,长度小于80),若找到,则将found单元置为ffh,并将匹配位置(匹配位置以字符串str首地址为0参考点)存放在pos单元中;否则,将found单元置为00H。要求编写完整程序,并上机通过调试能运行。
由于这是一道汇编语言的问题,我将提供 x86 汇编语言的解决方案。
首先,我们需要定义一些变量:
```assembly
str db 200h dup(0) ; 字符串 str,长度小于 200h
substr db 80 dup(0) ; 子串 substr,长度小于 80
found db 1 ; 用于存放是否找到子串的标志
pos dw 1 ; 用于存放匹配位置的偏移量
```
然后,我们需要定义一个子程序来计算字符串的长度:
```assembly
strlen:
push ax bx cx dx di
mov di, 0 ; di 用于计数
mov cx, 0FFFFh ; cx 用于循环计数
mov al, [si] ; si 指向字符串的首地址
repne scasb ; 扫描字符串
not cx ; cx 存储字符串长度
dec cx ; 不包括结束符 00h
mov di, cx ; 将字符串长度存入 di
pop di dx cx bx ax
ret
```
接下来,我们需要编写主程序来实现对子串的搜索:
```assembly
main:
mov si, offset str ; 将 si 指向字符串 str 的首地址
mov di, offset substr ; 将 di 指向子串 substr 的首地址
call strlen ; 计算字符串 str 的长度,结果存储在 di 中
mov bx, di ; 将字符串 str 的长度存储在 bx 中
call strlen ; 计算子串 substr 的长度,结果存储在 di 中
mov cx, bx ; 将字符串 str 的长度存储在 cx 中
mov si, offset str ; 将 si 指向字符串 str 的首地址
mov di, offset substr ; 将 di 指向子串 substr 的首地址
search:
cmp cx, di ; 比较字符串 str 的长度和子串 substr 的长度
jb notfound ; 如果字符串 str 的长度小于子串 substr 的长度,则未找到子串
mov dx, di ; 将子串 substr 的长度存储在 dx 中
mov al, [si + di - 1] ; 从字符串 str 中取出一个字符
cmp al, [di - 1] ; 从子串 substr 中取出一个字符进行比较
jne nextchar ; 如果不匹配,则继续比较下一个字符
dec di ; 如果匹配,则继续比较下一个字符
cmp di, 0 ; 如果子串 substr 已经比较完了,则找到了子串
je foundit
jmp search ; 继续比较下一个字符
nextchar:
mov di, dx ; 将子串 substr 的长度存储在 di 中
sub bx, 1 ; 将字符串 str 的长度减去 1
add si, 1 ; 将 si 指向下一个字符
jmp search ; 继续比较下一个字符
foundit:
mov [found], 0FFh ; 将 found 置为 0FFh,表示找到了子串
mov cx, si ; 将匹配位置存储在 cx 中
sub cx, offset str ; 计算匹配位置的偏移量
mov [pos], cx ; 将匹配位置存储在 pos 中
notfound:
mov ax, 4C00h ; 退出程序
int 21h
```
完整的程序如下所示:
```assembly
str db 200h dup(0)
substr db 80 dup(0)
found db 1
pos dw 1
strlen:
push ax bx cx dx di
mov di, 0
mov cx, 0FFFFh
mov al, [si]
repne scasb
not cx
dec cx
mov di, cx
pop di dx cx bx ax
ret
main:
mov si, offset str
mov di, offset substr
call strlen
mov bx, di
call strlen
mov cx, bx
mov si, offset str
mov di, offset substr
search:
cmp cx, di
jb notfound
mov dx, di
mov al, [si + di - 1]
cmp al, [di - 1]
jne nextchar
dec di
cmp di, 0
je foundit
jmp search
nextchar:
mov di, dx
sub bx, 1
add si, 1
jmp search
foundit:
mov [found], 0FFh
mov cx, si
sub cx, offset str
mov [pos], cx
notfound:
mov ax, 4C00h
int 21h
```
注意,此程序未经过测试,可能存在错误。在实际使用时,请先进行测试和调试。