Lzj0314 @ 2024-12-07 13:24:51
123456789对了,只有10错
#include<bits/stdc++.h>
using namespace std;
int main(){
char f[1200],a,ans;
int cnt[27],n,sum,c[27];
memset(cnt,0,sizeof(cnt));
memset(c,0,sizeof(cnt));
cin>>f;
n=strlen(f);
for(int i=0;i<n;i++){
a=f[i];
a=a-'a'+1;
cnt[a]++;
if(cnt[a]==1){sum++;c[sum]=a;}
}
for(int i=1;i<=26;i++){
if(cnt[c[i]]==1){
ans=c[i]+'a'-1;
cout<<ans;
return 0;
}
}
cout<<"no";
return 0;
}
by _th_tw_on_ @ 2024-12-07 13:32:32
@Lzj0314
#include<bits/stdc++.h>
using namespace std;
int main(){
char f[1200],a,ans;
int cnt[27],n,sum,c[27];
memset(c,0,sizeof(c));
memset(cnt,0,sizeof(cnt));
cin>>f;
n=strlen(f);
for(int i=0;i<n;i++){
a=f[i];
a=a-'a'+1;
cnt[a]++;
}
for(int i=0;i<n;i++){
if(cnt[f[i]-'a'+1]==1){
cout<<f[i];
return 0;
}
}
cout<<"no";
return 0;
}
by Lzj0314 @ 2024-12-07 13:37:00
悟了,谢谢