HDU 1113
来源:互联网 发布:完美主义 知乎 编辑:程序博客网 时间:2024/05/29 04:17
不复杂,只是写起来很麻烦……
#include "stdio.h"#include "string.h"#include "stdlib.h"typedef struct word{char s[7];int len;char* has[100];int k;}Word, *pWord;void sort(char* s, int len){int i, j;char t;for(i=1; i<len; i++){t = s[i];for(j=i-1; j>=0; j--){if(s[j] > t)s[j+1] = s[j];elsebreak;}s[j+1] = t;}}Word words[100];int p;char data[500][7];int num;int insert(int find, int* wh){char st[7];int i, k;int len;len = strlen(data[num]);strcpy(st, data[num]);sort(st, len);for(i=0; i<p; i++){if(words[i].len != len) continue;for(k=0; k<words[i].len; k++){if(st[k] != words[i].s[k])break;}if(k == words[i].len){if(find){*wh = i;return 1;}words[i].has[words[i].k++] = data[num];return 1;}}if(find) return 0;strcpy(words[p].s, st);words[p].len = len;words[p].has[0] = data[num];words[p].k = 1;p++;return 0;}void main(){int i, j;int wh;char* t;p = 0;num = 0;freopen("in.txt", "r", stdin);while(scanf("%s", data[num]), data[num][0]!='X'){insert(0, 0);num++;}while(scanf("%s", data[num]), data[num][0]!='X'){if(insert(1, &wh)){for(i=1; i<words[wh].k; i++){t = words[wh].has[i];for(j=i-1; j>=0; j--){if(strcmp(words[wh].has[j], t) > 0)words[wh].has[j+1] = words[wh].has[j];elsebreak;}words[wh].has[j+1] = t;}for(i=0; i<words[wh].k; i++)printf("%s\n", words[wh].has[i]);}elseprintf("NOT A VALID WORD\n");printf("******\n");num++;}}
- HDU 1113
- hdu-1113
- HDU 1113
- hdu 1113
- HDU 1113 解题报告
- HDU 1113 字典查找
- HDU 1113 Word Amalgamation
- hdu 1113 Word Amalgamation
- hdu(1113)Word Amalgamation
- HDU 1113 Word Amalgamation
- hdu 1113 Word Amalgamation
- HDU 1113 Word Amalgamation
- HDU 1113-Word Amalgamation
- hdu 1113 Word Amalgamation
- hdu 1113 Word Amalgamation
- hdu 1113 Word Amalgamation
- hdu-1113 Word Amalgamation
- HDU 1113 Word Amalgamation
- 判断网络状态 (在2G,3G,WIFI下测试均通过)
- Linux从Ftp上下载最新文件,并保存到指定目录(实现有点2--)
- about EThread
- Mountain Lion(美洲狮)谣言终极盘点
- 常用的正则表达式
- HDU 1113
- 使用SQLite3存储和读取数据
- eclipse 不自动编译java文件的问题
- TNSAnalysis
- NDK 之大门开启
- Extjs 文本框 TextField 添加点击(onclick)事件方法
- VS.NET环境下实现日志系统的几种方式
- 读《模板的声明和实现为何要放在头文件中?》有感
- c# 字符、汉字等转换