// 第一个只出现一次的字符.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
using namespace std;
void FirstNotRepeatChar(char *a)
{
if(a == NULL)
return;
int hashTable[256]={0};
char *p = a;
while(*p){
hashTable[*(p++)]++;}
p=a;
while(*p)
{
if(hashTable[*p]==1)
{
cout<<*p;return;
}
p++;
}
}
int main()
{
char *a="ababccdeff";
FirstNotRepeatChar(a);
system("pause");
return 0;
}
转载于:https://my.oschina.net/u/2350638/blog/499959