标签:color == href blank clu string target cin for
题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/994805283241443328
题解:
1 /* 2 *将字符串中的单个字符变为int值,用数组ans的下表保存。 3 */ 4 #include <iostream> 5 #include<string> 6 using namespace std; 7 const int MAXN = 200; 8 9 int main() { 10 string str1, str2; 11 cin >> str1 >> str2; 12 int ans[MAXN] = { 0 }; 13 for (int i = 0; i < str1.size(); i++) 14 ans[str1[i] - 48]++; 15 int count = 0, cnt = 0; 16 for (int i = 0; i < str2.size(); i++) { 17 int j = 0; 18 for (; j < str1.size(); j++) { 19 if (ans[str1[j] - 48] != 0 && str2[i] == str1[j]) { 20 ans[str1[j] - 48]--; 21 count++; 22 break;//容易忘记 23 } 24 } 25 if (j == str1.size()) cnt++; 26 } 27 if (count == str2.size()) cout << "Yes" << " " << str1.size() - str2.size(); 28 else cout << "No" << " " << cnt; 29 return 0; 30 }
标签:color == href blank clu string target cin for
原文地址:https://www.cnblogs.com/Gzu_zb/p/9567413.html