[c语言]EmailAddresses(for hw)
来源:互联网 发布:铁路工程预算软件 编辑:程序博客网 时间:2024/05/04 03:31
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.
Input
The first line is a positive integer for the number of e-mail addresses which is smaller than 50. 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>#include <stdlib.h>#include <ctype.h>//在快排的比较函数中,把字符串存放在另一个指针中,把这个指针中的字符转化为小写再排序。不能改变原来指针的内容!//尽量使用strncpy, 同时最后一个参数要用strlen()+ 1,表示加上字符串最后一个/0;int comp(const void*a, const void*b) { char p1[200]; char p2[200]; strncpy(p1, (char*)a, strlen((char*)a) + 1); strncpy(p2, (char*)b, strlen((char*)b) + 1); long length_1 = strlen(p1); long length_2 = strlen(p2); for (int i = 0; i < length_1; i++) { p1[i] = tolower(p1[i]); } for (int i = 0; i < length_2; i++) { p2[i] = tolower(p2[i]); } return strcmp((char*)p1,(char*)p2);}int main() { int n; scanf("%d", &n); char address[100][100]; int i = 0; while (n--) { scanf("%s", address[i]); i++; } qsort(address, i, sizeof(address[0]), comp); int m; for (m = 0; m < i - 1; m++) { if (strcmp(address[m], address[m + 1]) == 0) { strncpy(address[m], "0", strlen(address[m]) + 1); } } for (m = 0; m < i; m++) { if (strcmp(address[m], "0") != 0) { printf("%s\n", address[m]); } } return 0;}
- [c语言]EmailAddresses(for hw)
- EmailAddresses
- 程设课上题 Fraction [ For HW ]
- skill c for macro (c语言)
- 回文词(hw)
- hw
- hw
- HW
- HW
- hw
- Class streamManipulator(for hw) cout的应用
- Rocky's Requirements for ideal HW
- Cg(C for Graphic)语言概述
- Cg(C for Graphic)语言关键字
- .Cg(C for Graphic)语言概述
- C语言 for问题
- c 语言的for
- C语言for循环
- 嵌入式STMFD SP!,{R0-R7,LR}分析
- Matlab笔记-0
- C语言 数组长度...int length = sizeof(stu) / sizeof(stu[0]);
- 学校里的那首歌
- java温习笔记01:环境配置及编辑器设置
- [c语言]EmailAddresses(for hw)
- 黑马程序员——阶乘的两种实现方法及水仙花数的打印
- 【前端】JS
- RecyclerView的嵌套使用
- UITableView与初始MVC
- github比sourceforge好在哪?
- 2016年的第一天 开始自己的技术生涯
- 学习笔记 LeetCode 201. Bitwise AND of Numbers Range
- 第六届福建省大学生程序设计竞赛 Super Mobile Charger