题解
2025-07-11 22:24:23
发布于:江苏
5阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int l,y,e,s,s2,w,l2,q,b,j;
int main(){
string a;
cin >> a;
for (int i=0;i<a.length();i++){
if (a[i]=='0'){
l++;
}else if(a[i]=='1'){
y++;
}else if(a[i]=='2'){
e++;
}else if(a[i]=='3'){
s++;
}else if(a[i]=='4'){
s2++;
}else if(a[i]=='5'){
w++;
}else if(a[i]=='6'){
l2++;
}else if(a[i]=='7'){
q++;
}else if(a[i]=='8'){
b++;
}else{
j++;
}
}
if(l>0){
cout<<"0 = "<<l<<endl;
}
if(y>0){
cout<<"1 = "<<y<<endl;
}
if(e>0){
cout<<"2 = "<<e<<endl;
}
if(s>0){
cout<<"3 = "<<s<<endl;
}
if(s2>0){
cout<<"4 = "<<s2<<endl;
}
if(w>0){
cout<<"5 = "<<w<<endl;
}
if(l2>0){
cout<<"6 = "<<l2<<endl;
}
if(q>0){
cout<<"7 = "<<q<<endl;
}
if(b>0){
cout<<"8 = "<<b<<endl;
}
if(j>0){
cout<<"9 = "<<j<<endl;
}
return 0;
}
这里空空如也
有帮助,赞一个