728x90
반응형
1120 문자열
문제풀이
#include <iostream>
using namespace std;
void fast_io(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int main()
{
fast_io();
int res = 50;
string a, b;
cin >> a >> b;
for (int i = 0; i <= b.length() - a.length(); i++)
{
int cnt = 0;
for (int j = 0; j < a.length(); j++)
if (a[j] != b[j + i])
cnt++;
if (cnt < res)
res = cnt;
}
cout << res;
}
a 문자열을 b의 각 인덱스에 대입해보면서 비교 후 최소값을 출력했다.
728x90
반응형
'자라는 개발자 > 문제풀이' 카테고리의 다른 글
백준 c++ 3986 좋은 단어 (0) | 2022.01.26 |
---|---|
백준 c++ 1487 물건 팔기 (0) | 2022.01.25 |
백준 C++ 1439 뒤집기 (0) | 2022.01.23 |
백준 c++ 21156 A Rank Problem (0) | 2022.01.21 |
백준 c++ 10104 Party Invitation (1) | 2022.01.20 |