#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <math.h>


struct Item

{

struct Item *next;

int data;

char *name;

};


struct Item* FindItem(struct Item *head, char *name)

{

struct Item *curr = head;

while(curr)

{

if(curr->next != NULL)

{

if(curr->next->name == name)

{

return curr;

}

}

curr = curr->next;

}

return NULL;

}

void CreateItem(struct Item *head,char *name)

{

struct Item *node = malloc(sizeof(struct Item));

node->name = name;

node->data = NULL;

node->next = NULL;

struct Item *curr = head;

while(curr)

{

if(curr->next == 0)

{

curr->next = node;

break;

}

curr = curr->next;

}

}


int main()

{

struct Item *head = malloc(sizeof(struct Item));

head->data = 0;

head->next = NULL;

char* s1[100];

const char* str1 = "생성";

const char* str2 = "출력";

struct Item *node;

while(1)

{

scanf("%s",s1);

//생성할떄 같은아이템 체크하고 그기에 +1 하거나 없으면 뒤에 생성하는데
//이부분 성능이 반복문 2배나 드가니 성능안좋아보임.. 

//해결법있나요?

if (strcmp(s1, str1) == 0)

{

node = FindItem(head,"사탕");

if(node != NULL)

{

node->next->data += 1;

}

else 

{

CreateItem(head,"사탕");

}

}

if (strcmp(s1, str2) == 0)

{

Print(head);

}

}

return 0;

}