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;
}

  

时间: 2024-08-26 08:44:29

uva-10815-字符串排序的相关文章

UVA 156 Ananagrams 关于二维数组表示的字符串排序的问题

题目链接:UVA 156 Ananagrams  Ananagrams  Most crossword puzzle fans are used to anagrams--groups of words with the same letters in different orders--for example OPTS, SPOT, STOP, POTS and POST. Some words however do not have this attribute, no matter how

UVA 156-Ananagrams(字符串排序按序输出无重复单词)

Ananagrams Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Description  Ananagrams  Most crossword puzzle fans are used to anagrams--groups of words with the same letters in different orders--for example OPTS, SPO

UVa - 10815 Andy&#39;s First Dictionary(STL)

题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18649 #include <iostream> #include <string> #include <set> #include <sstream> using namespace std; /******************************************************************

Andy&#39;s First Dictionary UVA 10815

#include <stdio.h> #include <ctype.h> #include <string.h> #define MAXN 5000+5 #define MAXM 200+5 typedef struct Dic{ char str[MAXN]; struct Dic* next; }Dic; Dic *head; char word[MAXM]; int cnt=0; int get_word(); void convert_word(); void

F - Andy&#39;s First Dictionary (UVA - 10815)

- 题目大意 给出一段文章,然后将其中不重复的单词拿出来(全为小写并且由a-z的顺序). - 解题思路 我在网上看到的一个stringstream函数,它除了进行字符串和数字转换之外的另一个用途:分割单词.将字符串中所有非单词字符全部转换为空格,然后再用代码中的方法分割出单词.有这种方法就好做多了.结合set容器即可. - 代码 #include<iostream> #include<set> #include<string> #include<sstream&g

【UVA - 10815】Andy&#39;s First Dictionary (set)

Andy's First Dictionary Description 不提英文了 直接上中文大意吧 XY学长刚刚立下了再不过CET就直播xx的flag,为了不真的开启直播模式,XY学长决定好好学习英语.于是他每天都读一篇只包含生词的英语文章,并以自己高达450的智商在一秒钟之内记忆下来. 现在给你一篇XY学长今天要读的文章,请你写一个程序,输出他都学习到了哪些单词.要求:如果文章中有相同的单词,那么仅仅输出一次:而且如果两个单词只有大小写不同,将他们视为相同的单词. Input 测试数据将输入

UVA - 10815 Andy&#39;s First Dictionary

1 #include <iostream> 2 #include <cstring> 3 #include <algorithm> 4 #include <set> 5 using namespace std; 6 7 set<string> out; 8 9 int main() 10 { 11 string s,temp; 12 while(cin>>s) 13 { 14 int len(s.size()); 15 for(int

Openjudge-计算概论(A)-字符串排序

描述 参考整数排序方法,设计一种为字符串排序的算法,将字符串从小到大输出 输入 第一行为测试数据组数t, 后面跟着t组数据.每组数据第一行是n,表示这组数据有n行字符串,接下来是要排序的n行字符串.每行字符串的字符个数不会大于200, n < 100. 输出 对于每组数据,输出排好序的字符串,每组输出后要多输出一个空行 样例输入 2 2 Hello World 4 I Love C Language! 样例输出 Hello World C I Language! Love思路:这题可以把它们全部

UVa 10152 龟壳排序

思路:先读入的一列是原始串,后读入的一列是目标串.最少操作次数的方式是,从下到上,只对原始串进行删除而不放到最上面能得到的目标串的以最下元素开头的最长子串,然后将目标串剩余的那些按序放在最上方,即按由下到上的顺序输出即可. Code: //#define LOCAL #include<stdio.h> #include<stdlib.h> #include<string.h> char name[210][90]; char target[210][90]; //cha

gets()、puts()函数。字符串函数。字符串排序的例子。

1.实例程序:string.c的程序: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 #include<stdio.h> #define MSG "YOU MUST have many talents .tell me some." #define LIM 5 #define LINELEN 81 int main() { char name[LINELEN]; char