30分,不明白,求助!
查看原帖
30分,不明白,求助!
1627604
CoderMC楼主2025/1/10 10:39
#include<bits/stdc++.h>
using namespace std;
int cnt[100];
int main(){
    string s;
    cin>>s;
    int len=s.size();
 //   int cnt[100];
  //  len=getline(cin,s);
  // len=s.size();
    for(int i=0;i<len;i++){
        cnt[s[i]-'a']++;
    }
    bool f=false;
    for(int i=0;i<len;i++){
        if(cnt[s[i]]==1){
            f=true;
            cout<<s[i]<<endl;
            break;
        
        //return 0;//不符合写程序单出口原则,故采用bool
        }
    }
    if(f==false){
    cout<<"no";
    }
    return 0;
}
2025/1/10 10:39
加载中...