ZOJ-2876
来源:互联网 发布:知行天下品牌策划 编辑:程序博客网 时间:2024/06/17 17:22
数据比较水,直接排序之后前后两个判断前面那个串是否后面串的子串
#include<stdio.h>#include<string.h>#include<stdlib.h>static int cmp(const void *p1, const void *p2){char *s1 = (char *) p1;char *s2 = (char *) p2;return strcmp(s1, s2);}int main(){int t, n;char s[10000][11], temp[11];scanf("%d", &t);while (t--){scanf("%d", &n);while (getchar() != '\n');int i;for (i = 0; i < n; i++)gets(s[i]);qsort(s, n, sizeof(s[0]), cmp);for (i = 0; i < n - 1; i++)if (strlen(s[i]) <= strlen(s[i + 1])){strcpy(temp, s[i + 1]);temp[strlen(s[i])] = '\0';if (!strcmp(s[i], temp))break;}puts(i == n - 1 ? "YES" : "NO");}return 0;}
0 0
- ZOJ-2876
- zoj 2876 Phone List
- zoj 2876 Phone List
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- Eulerproblem-12 for python
- 100个windows平台C++开发错误之宏定义
- 操作系统实验四之进程同步实验
- 【深度探索 STL】【数据结构】详解红黑树(一)结构及插入
- 素因子分解&&素因子分解求最大公约数&&素因子分解求最小公倍数
- ZOJ-2876
- Cocos2d-x 程序是如何开始运行与结束的
- 100个windows平台C++开发错误之数组
- pySerial -- Python的串口通讯模块
- NOJ [1293] Porter Cai
- 年龄大了还可以学习编程吗
- oracle归档日志
- 【1】Maven安装
- 【LeetCode】Climbing Stairs