较水。
#include<iostream> using namespace std; int hashtable1[300] = {0},hashtable2[300]= {0}; int main() { string str1,str2; cin>>str1>>str2; for(int i = 0; i < str1.size(); i) hashtable1[str1[i]] ; for(int i = 0; i < str2.size(); i) hashtable2[str2[i]] ; int cnt1 = 0,cnt2 = 0;//分别表示多余的珠子和欠缺的珠子的总个数 for(int i = 0; i < 300; i) { //遍历两个hashtable if(hashtable1[i] >= hashtable2[i]) cnt1 = hashtable1[i] - hashtable2[i]; else cnt2 = hashtable2[i] - hashtable1[i]; } if(cnt2 != 0) printf("No %d",cnt2); else printf("Yes %d",cnt1); return 0; }