0
#include
#include
#include
int main(){
using namespace std;
string inp;
int nu;
char oup;
while(cin>>inp){
int len=inp.size();
vectornum(26,0);
for(int i=0;i
num[inp[i]-'a']++;
}
for(int j=0;j
if(num[inp[j]-'a']==1)
{nu=1;
oup=inp[j];
break;}
else nu=-1;
}
if(nu==1)cout<
else cout<
}
return 0;
}
发表于 2016-09-20 22:58:18
回复(0)
更多回答
32
#include
#include
int main()
{
using namespace std;
string str;
while(getline(cin,str))
{
unsigned int i;
for (i=0;i
{
if(str.find(str[i])==str.rfind(str[i]))
{
cout<
break;
}
}
if(i==str.size())
cout<
}
return 0;
}
发表于 2016-06-17 10:00:29
回复(12)
21
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
String str = sc.nextLine();
char[] cs = str.toCharArray();
for(int i = 0; i < cs.length; i++){
if(str.indexOf(cs[i]) == str.lastIndexOf(cs[i])){
System.out.println(cs[i]);
break;
}
}
}
sc.close();
}
}
发表于 2016-08-14 21:35:45
回复(8)
7
/*思路:每出现一次,就在对应数组中计数+1*/
#include
#include
using namespace std;
int main()
{
string str;
while(getline(cin,str))
{
int a[128]={0};//保存出现次数
bool flag=false;//判断是否找到
for(int i=0;i
++a[str[i]];
for(int i=0;i
if(a[str[i]]==1)//判断是否是第一个只出现一次的字符
{
cout<
flag=true;
break;//注意要break;
}
if(flag==false)//如果没有找到
cout<
}
return 0;
}
编辑于 2016-12-19 16:52:29
回复(3)
5
while True:
try:
string = input()
for i in string:
if string.count(i) == 1:
print(i)
break
else:
print(-1)
except:break
发表于 2020-03-27 23:54:10
回复(5)
5
用哈希统计词频
#include
#include
using namespace std;
const int tableS