您的位置:首页 > 大数据 > 人工智能

Sicily.Handling e-mail addresses

2016-01-01 15:45 387 查看
Description

[b]Time Limit: 1sec    Memory Limit:256MB
[/b]

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 order. Each 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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息