您的位置:首页 > 其它

找到第一个只出现一次的字符

2015-09-01 00:00 211 查看
// 第一个只出现一次的字符.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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: