#include <stdio.h>
#include <stdlib.h>
struct s_list
{
char c ;
struct s_list *next;
};
void creat_list(struct s_list **headp)
{
char ch;
struct s_list * loc_head = NULL,*tail;
if((ch = getchar()) == '\n');
else
{
loc_head = (struct s_list *)malloc(sizeof(struct s_list));
loc_head -> c = ch;
tail = loc_head;
while((ch = getchar()) != '\n')
{
tail -> next = (struct s_list *)malloc(sizeof(struct s_list));
tail = tail -> next;
tail -> c = ch;
}
tail -> next = NULL;
}
*headp = loc_head ;
}
void print_list(struct s_list *headp)
{
while(headp != NULL)
{
printf("%c",headp->c );
headp = headp -> next;
}
printf("\n");
}
void operate_list(struct s_list *headp)
{
char ch,ch_tmp;
int flag = 1;
while((ch = getchar()) != '\n')
{
struct s_list *current = headp ;
while(current != NULL)
{
if(current->c == ch) //delete note
{
struct s_list *tmp=headp;
flag = 0;
if(current==headp)
{
headp = headp->next;
print_list(headp);
break;
}
else
{
while(tmp->next != current)
{
tmp = tmp->next;
}
tmp->next = current->next;
print_list(headp);
break;
}
}
else
current = current -> next;
}
if(current == NULL)
{
struct s_list *tmpp = headp ;
ch_tmp = tmpp->c;
while(tmpp != NULL)
{
tmpp = tmpp->next;
if(tmpp != NULL)
if((ch_tmp - (tmpp->c)) < 0)
{
ch_tmp = tmpp->c;
}
}
struct s_list *tmp=headp;
while(tmp != NULL)
{
if(tmp->c==ch_tmp)
break;
else
{
tmp = tmp -> next;
}
}
struct s_list *loc_head=headp,*after = NULL;
while(tmp != loc_head)
{
loc_head = loc_head->next;
}
after=loc_head->next;
struct s_list *tmp0=NULL;
tmp0 = (struct s_list *)malloc(sizeof(struct s_list));
tmp0->c=ch;
tmp0->next=after;
loc_head->next=tmp0;
print_list(headp);
}
current=headp;
}
}
int main()
{
struct s_list *head = NULL;
creat_list(&head);
print_list(head);
operate_list(head);
return 0;
}