You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# include <iostream>
using namespace std ;
string a , b ;
int cnt , p = - 1 ;
/**
* to tomato不能匹配!
* @return
*/
int main ( ) {
//读入带空格的字符串
getline ( cin , a ) ;
getline ( cin , b ) ;
//a字符串转小写
a = ' ' + a + ' ' ;
for ( int i = 0 ; i < a . size ( ) ; i + + )
if ( a [ i ] > = ' A ' & & a [ i ] < = ' Z ' ) a [ i ] = a [ i ] + 32 ;
//b字符串转小写
b = ' ' + b + ' ' ;
for ( int i = 0 ; i < b . size ( ) ; i + + )
if ( b [ i ] > = ' A ' & & b [ i ] < = ' Z ' ) b [ i ] = b [ i ] + 32 ;
//在b字符串查找
for ( int i = 0 ; i < b . size ( ) ; i + + )
if ( b . substr ( i , a . size ( ) ) = = a ) {
cnt + + ;
//记录第一个位置
if ( p = = - 1 ) p = i ;
}
//输出
if ( cnt > 0 ) cout < < cnt < < " " < < p < < endl ;
else cout < < - 1 < < endl ;
return 0 ;
}