题解
2025-08-09 09:01:27
发布于:江苏
0阅读
0回复
0点赞
这道题只有abcd,那就单独判断即可
#include<bits/stdc++.h>
using namespace std;
string s;
bool a,b,c,d;
int ans;
int main()
{
cin >> s;
for(int i = 0;i <= s.size();i++)
{
if(s[i] == 'a' && !a)
{
ans++;
a = true;
}
else if(s[i] == 'b' && !b)
{
ans++;
b = true;
}
else if(s[i] == 'c' && !c)
{
ans++;
c = true;
}
else if(s[i] == 'd' && !d)
{
ans++;
d = true;
}
}
cout << ans << "\n";
return 0;
}
这里空空如也
有帮助,赞一个