又偷懒了,字符串排序,贱贱的用了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;
}