본문 바로가기
백준 알고리즘/그리디 알고리즘

백준 1120번 C++

by paysmile 2019. 8. 28.

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;
const int MAX = 51;
string a, b;

int mindiff(int k) {
	int answer = 0;

	for (int i = 0; i < a.length(); i++) {
		if (b[i + k] != a[i])
			answer++;
	}
	return answer;
}

int main(void) {
	int diff = 987654321;
	cin >> a >> b;

	for (int i = (b.length() - a.length()); i >= 0; i--) {
		diff = min(diff,mindiff(i));
	}
	cout << diff << endl;
	return 0;
}

'백준 알고리즘 > 그리디 알고리즘' 카테고리의 다른 글

대회 or 인턴 C++  (0) 2019.10.11
로프 C++  (0) 2019.10.10
백준 10610번 C++  (0) 2019.02.18
백준 1931번 C++  (0) 2019.02.18
백준 11047번 C++  (0) 2019.02.18