123 - Searching Quickly
来源:互联网 发布:淘宝模板化设置 编辑:程序博客网 时间:2024/05/21 22:30
#include <iostream>#include <string>#include <vector>#include <list>#include <cstring>using namespace std;struct comp {string title;string keyword;};bool has_ele ( vector<string> arr, string target ) {for ( auto e : arr ) {if ( e == target )return true;}return false;}bool foo1 ( const comp & lhs, const comp & rhs ) {return lhs.keyword < rhs.keyword;}int main ( int argc, char * argv[] ) {vector<string> vec_ign, vec_tit;list<comp> list_comp;string tmp_s;while ( cin >> tmp_s ) {if ( tmp_s != "::" ) {for ( auto & c : tmp_s ) c = tolower ( c );vec_ign.push_back ( tmp_s );} else {break;}}while ( getline ( cin, tmp_s ) ) {for ( auto & c : tmp_s ) c = tolower ( c );vec_tit.push_back ( tmp_s );}/* pre-process */for ( auto v : vec_tit ) {const char * ptr = v.c_str();int len = strlen ( ptr );int last = 0;int i, j;for ( i = 0; i < len; i++ ) {if ( ptr[ i ] == ' ' || i == len - 1 ) {int start = last, end = i - 1;if ( ptr[ i ] != ' ' && i == len - 1 ) end = i;char word[64];for ( j = start; j <= end; j++ ) word[ j - start ] = ptr [ j ];word [ end -start + 1 ] = '\0';tmp_s = word;if ( ! has_ele ( vec_ign, tmp_s ) ) {comp c1;c1.keyword = tmp_s;c1.title = v;for ( j = start; j <= end; j++ ) c1.title[ j ] = toupper ( c1.title[ j ] );list_comp.push_back ( c1 );}last = i + 1;}}}list_comp.sort ( foo1 );for ( auto l : list_comp ) {cout << l.title << endl;}return 0;}
0 0
- UVa 123 Searching Quickly
- uva 123 Searching Quickly
- UVA 123 - Searching Quickly
- uva 123 - Searching Quickly
- uva-123 - Searching Quickly
- 123 - Searching Quickly
- 123 - Searching Quickly
- UVaOJ 123 - Searching Quickly
- UVA 123 - Searching Quickly
- UVa 123 - Searching Quickly
- UVa 123 Searching Quickly
- uva 123 - Searching Quickly
- uva 123Searching Quickly
- 123 - Searching Quickly
- UVA 123 Searching Quickly
- uva 123 - Searching Quickly
- uva - 123 - Searching Quickly
- UVa - 123 - Searching Quickly
- online_judge_1488
- 请编写一个函数,它在一个字符串中进行搜索,查找所有 在一个给定字符集合中出现的字符。
- Jquery在页面加载后执行的三种方式
- 动态规划
- ubuntu14.04---多语言输入法的配置
- 123 - Searching Quickly
- 黑马程序员-IO-递归遍历文件夹中的全部文件,拷贝到另一个文件中,对每一个文件修改其后缀名
- IOS学习之UITabBarController和UITabBarButton
- 755 - 487--3279
- 107 - The Cat in the Hat
- Spring Framework源码(十二):SpringMVC之数据绑定、验证、转换
- 10014 - Simple calculations
- “ android 4.3 卡热插拔 自动识别卡类型 ”中AndroidManifest.xml路径
- Listener--监听器