자라는 개발자/문제풀이
백준 c++ 1120 문자열
자란다
2022. 1. 24. 22:21
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
반응형