uva-10815-字符串排序
Posted 菜菜
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了uva-10815-字符串排序相关的知识,希望对你有一定的参考价值。
又偷懒了,字符串排序,贱贱的用了std:map
#include <iostream> #include <sstream> #include<algorithm> #include<memory.h> #include<stdio.h> #include<map> #include<strstream> #include<istream> using namespace std; #define null NULL const int N = 300 * 5000; struct Node { string str; int hash; }; Node strs[N]; int length = 0; char ss[N]; int main() { freopen("d:\\1.txt", "r", stdin); string str; map<string, string> maps; int j = 0; while (cin >> str) { string s = ""; int l = str.length(); for (int i = 0; i < l; i++) { if (isalpha(str.at(i))) { char c = tolower(str.at(i)); ss[j++] = c; } else { ss[j++] = ‘ ‘; } } ss[j++] = ‘ ‘; } istringstream in(ss); while(in>>str) { maps.insert(pair<string, string>(str, str)); } map<string, string>::iterator it = maps.begin(); while (it != maps.end()) { cout << it->first << endl; it++; } return 0; }
以上是关于uva-10815-字符串排序的主要内容,如果未能解决你的问题,请参考以下文章