Sicily.Handling e-mail addresses

Description
Time Limit: 1sec    Memory Limit:256MB

You've gathered some e-mail addresses from a variety of sources, and you want to send out a mass mailing to all of the addresses. However, you don't want to send out duplicate messages. You need to write a program that reads all e-mail addresses and discards any that already have been input.


Use one of the list classes from this chapter, modifying it as necessary to work with string data, and to deal with up to 500 items.

Input

The first line is a positive integer for the number of e-mail addresses. Then each of the e-mail addresses is input in one line.

Output

Output the new mailing list in lexicographic orderEach e-mail address in one line.

Note: ignore letter case when comparing two e-mail addresses, but the output is case sensitive.

Sample Input
10
toocle01@netsun.com
chuangling@chuangling.net
zjykrc@163.com
hahdjx@163.com
5663@sohu.com
toocle01@netsun.com
chenql_008@163.com
tsmoql@alibaba.com.cn
LYC@hzlasiji.com
zjykrc@163.com
Sample Output
5663@sohu.com
chenql_008@163.com
chuangling@chuangling.net
hahdjx@163.com
LYC@hzlasiji.com
toocle01@netsun.com
tsmoql@alibaba.com.cn
zjykrc@163.com

#include <stdio.h>
#include <string.h>


void sort( char item[][30], int size){ //按字典升序排列
	for(int i = 1; i <= size-1; i++){
		for(int j = 1; j <= size-i; j++){
			if( strcasecmp(item[j], item[j+1]) > 0){ //冒泡排序 用得其中不区分大小写
				char temp[30];
				strcpy(temp, item[j]);
				strcpy(item[j],item[j+1]);
				strcpy(item[j+1],temp);
			}
		}
	}
	return;
}

int main(){
	int t;
	int point = 1; //指向下一个需要读入邮箱的位置
	char item[501][30] = {0};
	char lin[30];// 临时字符串 
	scanf("%d", &t);
	while(t--){
		char unique = 1;
		scanf("%s", lin);
		for(int i = 1; i <= point-1; i++){
			if( strcmp( lin, item[i]) == 0){ //判断读入的这个邮箱是否已经存在
				unique = 0;
				break;
			}
		}
		if( unique == 1){
			strcpy( item[point], lin); //如果这个邮箱没有重复则读入到item表里
			point++;
		}
		memset(lin,0,sizeof(lin));
	}
	sort(item,point-1); //字典排序
	for(int i = 1; i <= point-1; i++){
		printf("%s\n", item[i]);
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值