File tree 1 file changed +68
-0
lines changed
1 file changed +68
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments