PAT 1039 到底买不买 (20 分)
作者:
昭明ZMing | 来源:发表于
2019-06-06 14:08 被阅读0次#include <iostream>
using namespace std;
int main() {
string select, want;
cin >> select >> want;
for (int i = 0; i < want.length(); i++) {
for (int j = 0; j < select.length(); j++) {
if (select[j] == want[i]) {
want[i] = '#';
select[j] = '#';
}
}
}
int cnt1 = 0, cnt2 = 0;//缺少 多余
for (int i = 0; i < want.length(); i++)
if (want[i] != '#') cnt1++;
for (int i = 0; i < select.length(); i++)
if (select[i] != '#') cnt2++;
if (cnt1 != 0)
cout << "No " << cnt1;//输出空格
else
cout << "Yes " << cnt2;
return 0;
}
本文标题:PAT 1039 到底买不买 (20 分)
本文链接:https://www.haomeiwen.com/subject/spzyxctx.html
网友评论