Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.c
- // Uloha 3.2
- //
- // Created by Marcel Choma on 3.10.2014.
- // Copyright (c) 2014 Marcel Choma. All rights reserved.
- //
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #define CHILDS_NUMBER 26
- #define MAX_WORD_LENGTH 30
- #define MAX_WORD 10010
- typedef struct node
- {
- struct node *childs[CHILDS_NUMBER];
- }NODE;
- int main()
- {
- int pom=0, count = 0, max = 0;
- char letterArray[MAX_WORD_LENGTH];
- NODE *root, *p_act;
- root = (NODE *) malloc(sizeof(NODE));
- while(scanf("%s",letterArray) > 0 )
- {
- p_act = root;
- count = 0;
- char * p = letterArray;
- while (*p != '\0')
- {
- pom = *p - 'A';
- if (p_act->childs[pom] == NULL){
- p_act->childs[pom] = (NODE *) malloc(sizeof(NODE));
- }else
- count++;
- p_act = p_act->childs[pom];
- p++;
- }
- if (count >= max){
- max = count;
- count = 0;
- }
- }
- printf("%d\n", max);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment