求助。求助。输入两个字符串存入数组a和数组b中,若b串是a串的子串则输出yes,否则输出no

求助、求助,不能用strstr什么的。。。
- -是用C语言、、、也不能用指针、、、

第1个回答  2011-04-12
Scanner scanner = new Scanner(System.in);
System.out.print("请输入字符串a:");
String a = scanner.nextLine().toUpperCase();
System.out.print("请输入字符串b:");
String b = scanner.nextLine().toUpperCase();

if (a.indexOf(b) >= 0) {
System.out.println("Yes");
} else {
System.out.println("NO");
}
第2个回答  2011-04-12
java代码:
/* 判断字符串el中是否包含s2字符串 */
public static boolean isSub(String el, String s2) {
el = el.toUpperCase();
s2 = s2.toUpperCase();
if (el.indexOf(s2) >= 0) {
return true;
} else {
return false;
}
}本回答被网友采纳
第3个回答  2011-04-13
A: 字符串1
B: 字符串2

int pca, pcb, pc;
for(pca=0; A[pca]; ++pca)
{
pc = pca;
for(pcb=0; B[pcb]&&A[pc];++pcb, ++pc)
{
if(B[pcb]!=A[pc]) break;
}
if(!B[pcb]) break;
}

if(!B[pcb]) ? 子串 : 非子串