PTA 1039 到底买不买

1039 到底买不买

#include 
using namespace std;
int main()
{
	string s1, s2;
	cin >> s1 >> s2;
	int count1[128] = {0}, count2[128] = {0}, count3 = 0;
	for (int i = 0; i < s1.length(); i++)
		count1[s1[i]]++;
	for (int i = 0; i < s2.length(); i++)
		count2[s2[i]]++;
	bool flag = true;
	for (int i = 0; i < 128; i++)
		if (count1[i] >= count2[i])
			continue;
		else
		{
			flag = false;
			count3 += count2[i] - count1[i];
		}
	if (flag)
		cout << "Yes" << " " << s1.length() - s2.length();
	else
		cout << "No" << " " << count3;
}

你可能感兴趣的:(PTA自刷题,其他)