Nevergonna_CCF @ 2021-12-21 18:16:52
#include <iostream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
string str;
int vis[100001];
int main(){
cin >> str;
bool flag=true;
memset(vis, 1, sizeof(vis));
for(int i = 0; i < str.length(); i++){
if(vis[str[i]-'a']==1){
vis[str[i]-'a']=0;
for(int j = i+1; j < str.length();j++){
if(str[i]==str[j]){
flag=false;
break;
}
}
if(flag){
cout << str[i];
goto END;
}
else{
flag=true;
continue;
}
}
}
cout << "no";
END:return 0;
}
by Saliva_Yan @ 2021-12-21 18:53:53
memset(vis,1,sizeof(vis));
出锅了,换成for循环就行了
for(int i=0;i<=27;i++)vis[i]=1;
by Saliva_Yan @ 2021-12-21 18:54:34
@limuwen666
by doctorliu @ 2021-12-21 19:03:40
memset是每个字节赋一次值,int是四个字节32个二进制位,如果用memset(1)会变成
(以上为二进制表示) 最后结果是16843009