void insertlast(node** head) { if((*head)==NULL) (*head)=createnode(insertdata()); else { node* temp=(*head); while(temp->next!=NULL) temp=temp->next; temp->next=createnode(insertdata()); } }
void insertbeg(node** head) { node* temp=createnode(insertdata()); temp->next=(*head); (*head)=temp; }
int main() { char ch; int i,j,k,l; printf("How many data you want to insert?\n\t"); scanf("%d",&j); int arry[j]; printf("Insert data into the list for the first time.\n"); for(k=0;k<j;k++) { printf("Data[%d]--> ",k); scanf("%d",&arry[k]); } printf("Do you want to insert more data ?\n\t Press Y (yes) / N (no)\n"); ch = getch(); if( (ch == 'Y') || (ch == 'y') ) { printf("In which location you want to insert ? \n"); scanf("%d",&i); insertdata(arry,i,(j-1)); } printf("Do you want to delete data ?\n\t Press Y (yes) / N (no)\n"); ch = getch(); if( (ch == 'Y') || (ch == 'y') ) { printf("which location you want to delete ? \n"); scanf("%d",&i); deletedata(arry,i,(j-1)); } return 0; }
void insertn(node **head,int n) { if((*head)==NULL) { printf("List is empty"); return; } else if(count(*head)<n) { printf("invalid value"); return; } else if(n==1) insertbeg(&(*head)); else { node* temp=(*head); node* prev=temp; while(temp->next!=NULL && --n) { prev=temp; temp=temp->next; } prev->next=createnode(insertdata()); (prev->next)->next=temp; } }
int main() { int line; int i; struct list *head=NULL; scanf("%d",&line); // char* array = (char*)malloc(sizeof(char)*line); printf("hellolo\n"); for (i = 0; i < line; ++i) { char buf[254]; scanf("%s", buf); insertdata(&head, buf); } struct list *phead; while(head) { printf("%s\n", head->value); char df = findTheUni(head->value); printf("%c\n", df); phead=head->next; free(head->value); free(head); head = phead; } return 0; }