Skip to content

Commit 84a4c1e

Browse files
committed
done with the double list. working on big seq
1 parent 2b28194 commit 84a4c1e

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

biggest_seq.c

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
//https://thehuxley.com/problem/261?quizId=6096
4+
#define DEBUG if(0)
5+
#define MAX 100001
6+
typedef struct node
7+
{
8+
char item;
9+
struct node *next;
10+
}NODE;
11+
12+
NODE* create_list()
13+
{
14+
return NULL;
15+
}
16+
17+
NODE* add(NODE* head, char item[])
18+
{
19+
NODE* new_node = (NODE*) malloc(sizeof(NODE));
20+
strcpy();
21+
new_node->next = head;
22+
DEBUG printf("[[[%d]]]\t",new_node->item);
23+
return new_node;
24+
}
25+
26+
int is_empty(NODE* head)
27+
{return(head == NULL);}
28+
29+
void printer(NODE* head)
30+
{
31+
if(head == NULL) {printf("Lista vazia!\n");}
32+
while (head != NULL)
33+
{
34+
printf("[%d]",head->item);
35+
head = head->next;
36+
}
37+
printf("Fim da Lista!\n");
38+
}
39+
40+
NODE* search(NODE* head, int item)
41+
{
42+
DEBUG printf("to dentro do search\n");
43+
while (head != NULL)
44+
{
45+
if (head->item == item)
46+
{
47+
DEBUG printf("ENCONTREI MAIS UM!!! [%d]\n", item);
48+
return head;//retorna o endereço que contém o item
49+
}
50+
head = head->next;
51+
}
52+
return NULL;
53+
}
54+
55+
int main()
56+
{
57+
char input[MAX];
58+
int p = scanf("%s", input);
59+
NODE* lista1 = create_list(); //nó que aponta para nulo
60+
while (p != EOF)
61+
{
62+
lista1 = add(lista1,input);
63+
}
64+
65+
66+
67+
return 0;
68+
}

0 commit comments

Comments
 (0)