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 <bits/stdc++.h>
using namespace std ;
int main ( ) {
int i , j ;
int n1 , n2 ;
char char_sliver_one [ 50 ] = { ' 0 ' } ;
char char_sliver_two [ 50 ] = { ' 0 ' } ;
int sliver_one [ 50 ] ;
int sliver_two [ 50 ] ;
int flag ;
int times = 0 ;
cin > > times ;
while ( times - - ) {
cin > > char_sliver_one > > char_sliver_two ;
n1 = strlen ( char_sliver_one ) ;
n2 = strlen ( char_sliver_two ) ;
j = 0 ;
flag = 1 ;
//循环遍历将字符转为数字存进数组
for ( i = 0 ; i < n1 ; i + + )
sliver_one [ i ] = char_sliver_one [ i ] - 48 ;
for ( i = 0 ; i < n2 ; i + + )
sliver_two [ i ] = char_sliver_two [ i ] - 48 ;
while ( j < n1 & & flag > 0 ) //如果flag==0, 说明遍历之后没有一个不满足条件的
{
flag = 0 ; //一开始默认是成立的
for ( i = 0 ; i < n2 ; i + + ) {
if ( sliver_one [ i + j ] + sliver_two [ i ] > 3 ) //遍历找是否有不满足条件的
{
flag = 1 ; //如果确实不满足条件
j + + ;
break ;
}
}
}
if ( n1 < n2 + j ) cout < < " 最小长度为: " < < j + n2 < < endl ;
else cout < < " 最小长度为: " < < n1 < < endl ;
}
return 0 ;
}