求一个字符串中第一个出现无重复的字符
2015-08-11 20:28
337 查看
#include "stdafx.h" #include <string> #include <stdio.h> #include <iostream> using namespace std; char findStr(const char* str) { int p[256]; int i; for(i=0;i<256;i++) p[i]=0; i=0; while(str[i]!='\0') { p[str[i]]++; i++; } for(i=0;str[i]!='\0';i++) { if(p[str[i]]==1) { return str[i]; } } return 0; } int _tmain(int argc, _TCHAR* argv[]) { int m; cin>>m; cin.get(); char s[100]; for(int i=0;i<m;i++) { gets(s); cout<<findStr(s)<<endl; } return 0; }
相关文章推荐
- 多线程之多窗口卖票&线程之间的通信
- 从今天开始学OC,一天一更,让我们共同进步。
- SolrCloud中的文件与Collection管理
- scanf与scanf_s
- hdoj 2094 产生冠军
- nginx和tomcat整合
- iOS项目开发实战——iOS网络编程获取网页Html源代码
- tableView从后往前传值
- abap chain endchain
- 基于消息机制的异步架构之回调函数注册
- hdoj 1011 Starship Troopers 【树形DP + 01背包】
- 30-CSS-02-CSS(和html结合的方式三四)
- 30-CSS-03-CSS(基本选择器&优先级)
- 文件服务器资源管理器
- 201301 JAVA题目0-1级
- 最长重复子串,最长公共子序列, 最长公共子串
- HDU5375 Gray code
- Codeforces Round #315 -Primes or Palindromes?(回文&&素数)
- 网络流
- UDP简单通讯之二