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
Sample Output
[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; }
相关文章推荐
- 如何组织构建多文件 C 语言程序(二)
- 如何写好 C main 函数
- Lua和C语言的交互详解
- 关于C语言中参数的传值问题
- 简要对比C语言中三个用于退出进程的函数
- 深入C++中API的问题详解
- 基于C语言string函数的详解
- C语言中fchdir()函数和rewinddir()函数的使用详解
- C语言内存对齐实例详解
- C语言编程中统计输入的行数以及单词个数的方法
- C语言自动生成enum值和名字映射代码
- 使用C语言判断英文字符大小写的方法
- c语言实现的带通配符匹配算法
- C语言实现顺序表基本操作汇总
- C语言中计算正弦的相关函数总结
- 使用C语言详解霍夫曼树数据结构
- 探讨C语言的那些小秘密之断言
- C语言实现BMP转换JPG的方法
- 深入探讨C语言中局部变量与全局变量在内存中的存放位置
- C语言查找数组里数字重复次数的方法