Linux安全网 - Linux操作系统_Linux 命令_Linux教程_Linux黑客

会员投稿 投稿指南 本期推荐:
搜索:
您的位置: Linux安全网 > Linux编程 > » 正文

uva10851--String暴力

来源: huzhengnan 分享至:

暴力很好写。。我还是太嫩了。。

//#define LOCAL
#include <stdio.h>
#include <string.h>
#include <ctype.h> 
#include <stdlib.h> 

#define MAXN 1000010 + 10
#define MAX 200 + 10

int cmp(const void *_a, const void *_b);

char word[MAXN][MAX];
int n = 0, len = 0;

int main()
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	int i;
	char temp;
	while(1)
	{
		// 数据输入 
		if((temp = getchar()) == EOF)
			break;
		if(isalpha(temp))
			word[n][len++] = tolower(temp);
		else if(isalpha(word[n][0]))
		{
			word[n++][len] = '\0';
			len = 0;
		}
		 
	}
	
	qsort(word, n, sizeof(word[0]), cmp);
	
	for(i = 0; i < n; i++)
	{
		if(strcmp(word[i], word[i + 1]))
			printf("%s\n", word[i]);
	}
	return 0;
}

int cmp(const void *_a, const void *_b)
{
	char *a = (char *) _a;
	char *b = (char *) _b;
	return strcmp(a, b);
}



Tags:
分享至:
最新图文资讯
1 2 3 4 5 6
验证码:点击我更换图片 理智评论文明上网,拒绝恶意谩骂 用户名:
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 发展历史