کدهای جاوا -رشته
پنجشنبه, ۱ آبان ۱۳۹۹، ۰۴:۵۰ ب.ظ
package ohgoood;
import java.util.Scanner;
public class khob {
static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
// TODO code application logic here
String s=scanner.nextLine();
//System.out.println("hi");
String one,two,whole[];
whole=s.split(" ",2);
one=whole[0];
two=whole[1];
// String one=scanner.next();
// String two=scanner.next();
System.out.println(StringInString(one,two));
}
public static int StringInString(String one, String two) {
int cnt=0;
for(int i=0;i+two.length()<=one.length();i++)
{
if(one.substring(i, i+two.length()).equals(two))
cnt++;
}
// if(one.substring(i,Math.min( i+two.length(),one.length())).equals(two))
return cnt;
}
}
۹۹/۰۸/۰۱