Files
python/RuMenJingDian/UVa/UVa1588.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

45 lines
1.3 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}